projects
/
contrib
/
mraa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ef28607
)
mraa.c: Fix ressource leaks during error handling
author
Brendan Le Foll
<brendan.le.foll@intel.com>
Thu, 13 Aug 2015 14:25:59 +0000
(15:25 +0100)
committer
Brendan Le Foll
<brendan.le.foll@intel.com>
Thu, 13 Aug 2015 14:25:59 +0000
(15:25 +0100)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
src/mraa.c
patch
|
blob
|
history
diff --git
a/src/mraa.c
b/src/mraa.c
index
d49be29
..
9f0c57a
100644
(file)
--- a/
src/mraa.c
+++ b/
src/mraa.c
@@
-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;