libselinux: free memory in error branch

In case the allocation for the filename fails, free the memory of the context.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
Christian Göttsche 2022-05-10 19:45:51 +02:00 committed by James Carter
parent 7e979b56fd
commit 8266fd9401

View file

@ -497,13 +497,15 @@ static int filespec_add(ino_t ino, const char *con, const char *file,
goto oom_freefl;
fl->file = strdup(file);
if (!fl->file)
goto oom_freefl;
goto oom_freeflcon;
fl->next = prevfl->next;
prevfl->next = fl;
__pthread_mutex_unlock(&fl_mutex);
return 0;
oom_freeflcon:
free(fl->con);
oom_freefl:
free(fl);
oom: