summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJase Thew <bazerka@irssi.org>2011-02-10 06:45:51 +0000
committerbazerka <bazerka@dbcabf3a-b0e7-0310-adc4-f8d773084564>2011-02-10 06:45:51 +0000
commit444b42bf3e2dd55fe99f96251b982188bdea12e7 (patch)
treeeddc8f355db5af93b21ff027a90cdb74af0d0e33 /src
parent2bee6f12ae028bba82e55cf5d38bd562d59726ef (diff)
downloadirssi-444b42bf3e2dd55fe99f96251b982188bdea12e7.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/irc/core/irc-expandos.c12
1 files 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 "";
}