packet-k12: Fix small memory leak

Use g_strsplit/g_strfreev instead of wmem_strsplit/wmem_free because in
wmem_strutil.h the wmem_strsplit is documented not to be used with a
NULL alocator.

5 bytes in 1 blocks are definitely lost in loss record 63 of 9,354
   at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
   by 0x4E8D3C5: g_malloc (gmem.c:99)
   by 0x8214317: wmem_alloc (wmem_core.c:37)
   by 0x8219227: wmem_strdup (wmem_strutl.c:41)
   by 0x8219AC1: wmem_strsplit (wmem_strutl.c:272)
   by 0x749E3C9: protos_chk_cb (packet-k12.c:363)

5 bytes in 1 blocks are definitely lost in loss record 64 of 9,354
   at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
   by 0x4E8D3C5: g_malloc (gmem.c:99)
   by 0x8214317: wmem_alloc (wmem_core.c:37)
   by 0x8219227: wmem_strdup (wmem_strutl.c:41)
   by 0x8219AC1: wmem_strsplit (wmem_strutl.c:272)
   by 0x749E24A: k12_copy_cb (packet-k12.c:327)

Change-Id: I994769d17c87ed1d4f620379a2502452f48d80a5
Reviewed-on: https://code.wireshark.org/review/28779
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
Vasil Velichkov 2018-07-20 21:12:06 +03:00 committed by Pascal Quantin
parent 9b731e2b32
commit 231cc0501a
1 changed files with 6 additions and 6 deletions

View File

@ -324,7 +324,7 @@ k12_copy_cb(void* dest, const void* orig, size_t len _U_)
{
k12_handles_t* d = (k12_handles_t *)dest;
const k12_handles_t* o = (const k12_handles_t *)orig;
gchar** protos = wmem_strsplit(NULL,d->protos,":",0);
gchar** protos = g_strsplit(d->protos,":",0);
guint num_protos;
for (num_protos = 0; protos[num_protos]; num_protos++)
@ -334,7 +334,7 @@ k12_copy_cb(void* dest, const void* orig, size_t len _U_)
d->protos = g_strdup(o->protos);
d->handles = (dissector_handle_t *)g_memdup(o->handles,(guint)(sizeof(dissector_handle_t)*(num_protos+1)));
wmem_free(NULL, protos);
g_strfreev(protos);
return dest;
}
@ -360,7 +360,7 @@ protos_chk_cb(void* r _U_, const char* p, guint len, const void* u1 _U_, const v
g_strstrip(line);
ascii_strdown_inplace(line);
protos = wmem_strsplit(NULL,line,":",0);
protos = g_strsplit(line,":",0);
for (num_protos = 0; protos[num_protos]; num_protos++)
g_strstrip(protos[num_protos]);
@ -368,7 +368,7 @@ protos_chk_cb(void* r _U_, const char* p, guint len, const void* u1 _U_, const v
if (!num_protos) {
*err = g_strdup("No protocols given");
wmem_free(NULL, line);
wmem_free(NULL, protos);
g_strfreev(protos);
return FALSE;
}
@ -376,13 +376,13 @@ protos_chk_cb(void* r _U_, const char* p, guint len, const void* u1 _U_, const v
if (!find_dissector(protos[i])) {
*err = g_strdup_printf("Could not find dissector for: '%s'",protos[i]);
wmem_free(NULL, line);
wmem_free(NULL, protos);
g_strfreev(protos);
return FALSE;
}
}
wmem_free(NULL, line);
wmem_free(NULL, protos);
g_strfreev(protos);
return TRUE;
}