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>
This commit is contained in:
Kai Vehmanen 2022-12-19 17:15:36 +02:00 committed by Kai Vehmanen
parent 19416908dd
commit 4d64893b86
1 changed files with 5 additions and 0 deletions

View File

@ -223,6 +223,11 @@ static void *wait_open(const char *watched_dir, const char *expected_file)
char * const fpath = malloc(strlen(watched_dir) + 1 + strlen(expected_file) + 1);
if (!fpath) {
fprintf(stderr, "error: can't allocate memory\n");
exit(EXIT_FAILURE);
}
strcpy(fpath, watched_dir);
strcat(fpath, "/");
strcat(fpath, expected_file);