On Sat, 27 Nov 2010 05:10:15 +0100, Corbin Simpson
<[email protected]> wrote:
On Fri, Nov 26, 2010 at 4:34 PM, Jesse Adkins <[email protected]>
wrote:
I had to backspace after the 'char' and before '**reasonMsgs' to get
this to apply. Perhaps the git repo has been updated since this patch.
Aside from that, it applies.
Some mailer issue? The source file hasn't been changed since Jan 2009.
I have no problems git am'ing my e-mail.
Can you comment on why this is needed, either in the code or in the
git commit? Is there anything that can be done to trigger this leak? I
have no problem with giving this a test, but I've never heard of a
leak in libSM when running X in valgrind mode or using it on clients.
I have attached a completely foolish program that triggers both memory
leaks, and I'm quite certain that they can be triggered in less
pathological situations.
Is it proper convention to cast arguments to free() as char* in this
lib? I'd rather just leave it uncasted.
So would I, but I considered it more important to maintain the existing
style.
If "new" style is considered more important I'll send a new patch.
Shutting up Valgrind is always important, even if the leak in question
is trivial.
Reviewed-by: Corbin Simpson <[email protected]>
Thanks, added to patch.
/Kim
/*
* gcc -g -O -W -Wall -Wno-unused -o sm sm.c -lSM -lICE
*/
#include <stdlib.h>
#include <X11/SM/SMlib.h>
static SmcConn sm_conn = NULL;
static SmPointer sm_context;
static char *sm_client_id = "SM client";
int
main(int argc, char **argv)
{
char error_string_ret[4096];
sm_conn =
SmcOpenConnection(NULL, &sm_context, SmProtoMajor, SmProtoMinor, 0, NULL,
sm_client_id, &sm_client_id,
sizeof(error_string_ret), error_string_ret);
SmcInteractRequest(sm_conn, 0, NULL, NULL);
SmcInteractRequest(sm_conn, 1, NULL, NULL);
SmcRequestSaveYourselfPhase2(sm_conn, NULL, NULL);
SmcCloseConnection(sm_conn, 0, NULL);
return 0;
}
>From a5c88ae7a43de2809f8873167980c6e868627ed2 Mon Sep 17 00:00:00 2001
From: Kim Woelders <[email protected]>
Date: Sat, 30 Oct 2010 10:00:13 +0200
Subject: [PATCH libSM] Fix some potential memory leaks in SmcCloseConnection().
Signed-off-by: Kim Woelders <[email protected]>
Reviewed-by: Corbin Simpson <[email protected]>
diff --git a/src/sm_client.c b/src/sm_client.c
index a5c714f..5454398 100644
--- a/src/sm_client.c
+++ b/src/sm_client.c
@@ -325,6 +325,22 @@ SmcCloseConnection(SmcConn smcConn, int count, char **reasonMsgs)
if (smcConn->client_id)
free (smcConn->client_id);
+ if (smcConn->interact_waits)
+ {
+ _SmcInteractWait *ptr = smcConn->interact_waits;
+ _SmcInteractWait *next;
+
+ while (ptr)
+ {
+ next = ptr->next;
+ free ((char *) ptr);
+ ptr = next;
+ }
+ }
+
+ if (smcConn->phase2_wait)
+ free (smcConn->phase2_wait);
+
if (smcConn->prop_reply_waits)
{
_SmcPropReplyWait *ptr = smcConn->prop_reply_waits;
--
1.7.3.2
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel