comparison mcabber/mcabber/screen.c @ 2226:c1eb68306520

Fix memleak on replacing nickcolor rules
author Myhailo Danylenko <isbear@ukrpost.net>
date Tue, 12 Mar 2013 01:23:02 +0200
parents dc3b3ac1ba76
children 387cea2a1a81
comparison
equal deleted inserted replaced
2225:dc3b3ac1ba76 2226:c1eb68306520
348 scr_LogPrint(LPRINT_NORMAL, "No such color name"); 348 scr_LogPrint(LPRINT_NORMAL, "No such color name");
349 g_free(snick); 349 g_free(snick);
350 g_free(mnick); 350 g_free(mnick);
351 } else { 351 } else {
352 nickcolor *nc = g_new(nickcolor, 1); 352 nickcolor *nc = g_new(nickcolor, 1);
353 nickcolor *oc;
353 ensure_string_htable(&nickcolors, NULL); 354 ensure_string_htable(&nickcolors, NULL);
354 nc->manual = TRUE; 355 nc->manual = TRUE;
355 nc->color = cl; 356 nc->color = cl;
356 // Free the struct, if any there already 357 // Free the struct, if any there already
357 g_free(g_hash_table_lookup(nickcolors, mnick)); 358 if ((oc = g_hash_table_lookup(nickcolors, mnick))) {
359 g_free(oc -> color);
360 g_free(oc);
361 }
358 // Save the new ones 362 // Save the new ones
359 g_hash_table_replace(nickcolors, mnick, nc); 363 g_hash_table_replace(nickcolors, mnick, nc);
360 g_hash_table_replace(nickcolors, snick, nc); 364 g_hash_table_replace(nickcolors, snick, nc);
361 need_update = TRUE; 365 need_update = TRUE;
362 } 366 }