Private
Public Access
2
0

mraa.c: Fix ressource leaks during error handling

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-08-13 15:25:59 +01:00
parent ef28607cea
commit 45133922aa

View File

@@ -354,6 +354,9 @@ mraa_file_contains(const char* filename, const char* content)
size_t len = 1024;
char* line = malloc(len);
FILE* fh = fopen(file, "r");
if (fh == NULL) {
return 0;
}
while ((getline(&line, &len, fh) != -1) && (found == 0)) {
if (strstr(line, content)) {
found = 1;
@@ -380,6 +383,9 @@ mraa_file_contains_both(const char* filename, const char* content, const char* c
size_t len = 1024;
char* line = malloc(len);
FILE* fh = fopen(file, "r");
if (fh == NULL) {
return 0;
}
while ((getline(&line, &len, fh) != -1) && (found == 0)) {
if (strstr(line, content) && strstr(line, content2)) {
found = 1;