Stefan Schuermans commited on 2020-05-24 08:53:38
Showing 2 changed files, with 14 additions and 5 deletions.
... | ... |
@@ -52,9 +52,15 @@ int uptev_stringlist_read(char const *pathname, size_t *n, char ***strs, |
52 | 52 |
free(data); |
53 | 53 |
return -1; |
54 | 54 |
} |
55 |
- /* success: add malloc-ed object to cleaner and return string array */ |
|
56 |
- uptev_cleaner_add_ptr(cleaner, data); |
|
57 |
- uptev_cleaner_add_ptr(cleaner, ptrs); |
|
55 |
+ /* add malloc-ed object to cleaner */ |
|
56 |
+ if (uptev_cleaner_add_ptr(cleaner, data) != 0) { |
|
57 |
+ free(ptrs); |
|
58 |
+ return -1; |
|
59 |
+ } |
|
60 |
+ if (uptev_cleaner_add_ptr(cleaner, ptrs) != 0) { |
|
61 |
+ return -1; |
|
62 |
+ } |
|
63 |
+ /* success: return string array */ |
|
58 | 64 |
*n = cnt; |
59 | 65 |
*strs = ptrs; |
60 | 66 |
return 0; |
... | ... |
@@ -40,7 +40,10 @@ char *uptev_symlink_read(char const *pathname, uptev_cleaner_t *cleaner) { |
40 | 40 |
if (!target) { |
41 | 41 |
return NULL; |
42 | 42 |
} |
43 |
- /* success: add malloc-ed object to cleaner and return target string */ |
|
44 |
- uptev_cleaner_add_ptr(cleaner, target); |
|
43 |
+ /* add malloc-ed object to cleaner */ |
|
44 |
+ if (uptev_cleaner_add_ptr(cleaner, target) != 0) { |
|
45 |
+ return NULL; |
|
46 |
+ } |
|
47 |
+ /* success, return target string */ |
|
45 | 48 |
return target; |
46 | 49 |
} |
47 | 50 |