diff mbox series

[3/5] libselinux: fix memory leak in customizable_init()

Message ID 20231109135315.44095-3-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit d858afcaac2a
Delegated to: Petr Lautrbach
Headers show
Series [1/5] semodule_link: avoid NULL dereference on OOM | expand

Commit Message

Christian Göttsche Nov. 9, 2023, 1:53 p.m. UTC
Reported by Clang Analyzer:

    is_customizable_type.c:36:3: warning: Potential leak of memory pointed to by 'buf' [unix.Malloc]
       36 |                 fclose(fp);
          |                 ^~~~~~

Fixes: 9911f2ac6f77 ("libselinux: check for stream rewind failures")
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libselinux/src/is_customizable_type.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/libselinux/src/is_customizable_type.c b/libselinux/src/is_customizable_type.c
index 9be50174..da301c60 100644
--- a/libselinux/src/is_customizable_type.c
+++ b/libselinux/src/is_customizable_type.c
@@ -33,6 +33,7 @@  static void customizable_init(void)
 	}
 
 	if (fseek(fp, 0L, SEEK_SET) == -1) {
+		free(buf);
 		fclose(fp);
 		return;
 	}