Skip to content

Commit 43cd115

Browse files
committed
sof-logger: exit with error if malloc fails
In user-space tools, memory allocations can reasonably be expected to always succeed. Make this assumption explicit by adding error handling after malloc. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 764ce67 commit 43cd115

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/logger/logger.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ static void *wait_open(const char *watched_dir, const char *expected_file)
223223

224224
char * const fpath = malloc(strlen(watched_dir) + 1 + strlen(expected_file) + 1);
225225

226+
if (!fpath) {
227+
fprintf(stderr, "error: can't allocate memory\n");
228+
exit(EXIT_FAILURE);
229+
}
230+
226231
strcpy(fpath, watched_dir);
227232
strcat(fpath, "/");
228233
strcat(fpath, expected_file);

0 commit comments

Comments
 (0)