* memory leak in services.c
@ 2005-08-26 17:13 Jason Tang
2005-08-26 18:15 ` Stephen Smalley
0 siblings, 1 reply; 2+ messages in thread
From: Jason Tang @ 2005-08-26 17:13 UTC (permalink / raw)
To: selinux
[-- Attachment #1: Type: text/plain, Size: 191 bytes --]
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.
--
Jason Tang / jtang@tresys.com
[-- Attachment #2: patch-memleak --]
[-- Type: text/plain, Size: 466 bytes --]
--- services.c-old 2005-08-26 12:19:01.000000000 -0400
+++ services.c 2005-08-26 12:18:18.000000000 -0400
@@ -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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: memory leak in services.c
2005-08-26 17:13 memory leak in services.c Jason Tang
@ 2005-08-26 18:15 ` Stephen Smalley
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Smalley @ 2005-08-26 18:15 UTC (permalink / raw)
To: Jason Tang; +Cc: selinux
On Fri, 2005-08-26 at 13:13 -0400, Jason Tang wrote:
> 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.
--
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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-08-26 18:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-26 17:13 memory leak in services.c Jason Tang
2005-08-26 18:15 ` Stephen Smalley
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.