Skip to contentSkip to conversation

memory leak in services.c

PATCH Jason Tang 2 participants 2 messages Aug 26, 2005 SELinux security module

lore
Share & tools
lore

Jason Tang

author
#0 lore raw

The following patch corrects a memory leak in sepol_context_to_sid() within libsepol/services.c. The context was malloc()ed but never free()ed afterwards.

Signature · 1 line
Jason Tang / [email protected]
services.c renamed from services.c-old +4 -1
@@ -548,11 +548,14 @@ int sepol_context_to_sid(sepol_security_
 		goto err;		
 
 	context_destroy(context);
+        free(context);
 	return STATUS_SUCCESS;
 
 	err:
-	if (context)
+	if (context) {
 		context_destroy(context);
+                free(context);
+        }
 	DEBUG(__FUNCTION__, "could not convert %s to sid\n", scontext);
 	return STATUS_ERR;
 }
#1 lore raw
Quoted 3 lines · Jason Tang

The following patch corrects a memory leak in sepol_context_to_sid() within libsepol/services.c. The context was malloc()ed but never free()ed afterwards.

Hmmm...suggests that the introduction of the sepol_ctx_struct_from_string() helper may lead to confusion because it hides the allocation internally, and context_destroy doesn't free the context struct itself. Possibly a bad interface choice. But I'll merge this patch for now.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.