libselinux: free memory in error branch
PATCH 1/1 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 <[email protected]>
--- libselinux/src/selinux_restorecon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
libselinux/src/selinux_restorecon.c +3 -1
@@ -489,13 +489,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:
Signature · 1 line
2.36.1
Quoted 4 lines · Christian Göttsche
In case the allocation for the filename fails, free the memory of the context.
Signed-off-by Christian Göttsche <[email protected]>
Acked-by James Carter <[email protected]>
Quoted 28 lines
--- libselinux/src/selinux_restorecon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)libselinux/src/selinux_restorecon.c +3
-2@@ -489,13 +489,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: --2.36.1
Quoted 10 lines · James Carter
Quoted 4 lines · Christian Göttsche
In case the allocation for the filename fails, free the memory of the context.
Signed-off-by Christian Göttsche <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 28 lines
Quoted 28 lines
--- libselinux/src/selinux_restorecon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)libselinux/src/selinux_restorecon.c +3
-2@@ -489,13 +489,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: --2.36.1