mirror of https://github.com/thesofproject/sof.git
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:
parent
19416908dd
commit
4d64893b86
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue