From 444b42bf3e2dd55fe99f96251b982188bdea12e7 Mon Sep 17 00:00:00 2001 From: Jase Thew Date: Thu, 10 Feb 2011 06:45:51 +0000 Subject: [PATCH] Ensure that expando_cumode_space() doesn't free unallocated memory when no prefix exists by conditionally allocating and marking to-be-freed the cumode string inside of expando_cumode(). (Bug #669) git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@5203 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/core/irc-expandos.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/irc/core/irc-expandos.c b/src/irc/core/irc-expandos.c index 0c0da643..a1030624 100644 --- a/src/irc/core/irc-expandos.c +++ b/src/irc/core/irc-expandos.c @@ -87,11 +87,13 @@ static char *expando_cumode(SERVER_REC *server, void *item, int *free_ret) { if (IS_IRC_CHANNEL(item) && CHANNEL(item)->ownnick) { char prefix = NICK(CHANNEL(item)->ownnick)->prefixes[0]; - char *cumode = g_malloc(2); - cumode[0] = prefix; - cumode[1] = '\0'; - *free_ret = TRUE; - return cumode; /* will be "\0\0" = "" if there is no prefix */ + if (prefix != '\0') { + char *cumode = g_malloc(2); + cumode[0] = prefix; + cumode[1] = '\0'; + *free_ret = TRUE; + return cumode; + } } return ""; }