From 68cb4891010f9fbf682d6a089f3b37b435e55264 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Wed, 2 May 2012 13:13:06 +0300 Subject: [PATCH] wispr: Use g_strdup() instead of strdup() Valgrind reports following error if strdup() is used here: ==12572== Invalid read of size 4 ==12572== at 0x429113B: ??? (in /lib/libc-2.11.90.so) ==12572== by 0x80A8154: wispr_route_request (wispr.c:471) ==12572== by 0x805CA4F: resolv_result (gweb.c:449) ==12572== by 0x805DD4B: sort_and_return_results (gresolv.c:494) ==12572== by 0x805E285: received_udp_data (gresolv.c:705) ==12572== by 0x40AD8E6: ??? (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x4078AFA: g_main_context_dispatch (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x407911E: ??? (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x40796BC: g_main_loop_run (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x807400F: main (main.c:508) ==12572== Address 0x55f406c is 20 bytes inside a block of size 22 alloc'd ==12572== at 0x4029AE9: malloc (vg_replace_malloc.c:236) ==12572== by 0x40B1D6C: g_malloc (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x40B4C25: g_strdup (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x805CA23: resolv_result (gweb.c:1222) ==12572== by 0x805DD4B: sort_and_return_results (gresolv.c:494) ==12572== by 0x805E285: received_udp_data (gresolv.c:705) ==12572== by 0x40AD8E6: ??? (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x4078AFA: g_main_context_dispatch (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x407911E: ??? (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x40796BC: g_main_loop_run (in /lib/libglib-2.0.so.0.2800.6) ==12572== by 0x807400F: main (main.c:508) ==12572== If g_strdup() is used then no error is printed. This error does not make much sense but anyway use g_strdup() like in other parts of this file. --- src/wispr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wispr.c b/src/wispr.c index 034cced..f44a21a 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -468,7 +468,7 @@ static gboolean wispr_route_request(const char *address, int ai_family, return FALSE; } - route->address = strdup(address); + route->address = g_strdup(address); route->if_index = if_index; wp_context->route_list = g_slist_prepend(wp_context->route_list, route); -- 2.7.4