Skip to contentSkip to conversation

libsepol: fix memory leak in sepol_bool_query()

PATCH Applied [email protected] 2 participants 2 messages Sep 13, 2017 – Sep 20, 2017 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: fix memory leak in sepol_bool_query()

From: Jan Zarsky <[email protected]>

When sepol_bool_query() returns NULL response, variable name is not freed. Fix this by calling free() before returning.

---
 libsepol/src/booleans.c | 1 +
 1 file changed, 1 insertion(+)
libsepol/src/booleans.c +1 -0
index c914a28..30fcf29 100644
@@ -155,6 +155,7 @@ int sepol_bool_query(sepol_handle_t * handle,
 	booldatum = hashtab_search(policydb->p_bools.table, name);
 	if (!booldatum) {
 		*response = NULL;
+		free(name);
 		return STATUS_SUCCESS;
 	}
 
Signature · 1 line
2.9.5
#1 lore raw
Quoted 6 lines · On Wed, 2017-09-13 at 10:16 +0200, [email protected] wrote:

From: Jan Zarsky <[email protected]>

When sepol_bool_query() returns NULL response, variable name is not freed. Fix this by calling free() before returning.

Thanks, applied.

Quoted 16 lines

---
 libsepol/src/booleans.c | 1 +

 1 file changed, 1 insertion(+)
libsepol/src/booleans.c +1 -0
index c914a28..30fcf29 100644
@@ -155,6 +155,7 @@ int sepol_bool_query(sepol_handle_t * handle,
  	booldatum = hashtab_search(policydb->p_bools.table, name);
  	if (!booldatum) {
  		*response = NULL;
+		free(name);
  		return STATUS_SUCCESS;
  	}