block/curl: Fix wrong free statement

Submitted by Stefan Weil on Sept. 1, 2012, 9:06 a.m.

Details

Message ID 1346490405-18889-1-git-send-email-sw@weilnetz.de
State Accepted
Headers show

Commit Message

Stefan Weil Sept. 1, 2012, 9:06 a.m.
Report from smatch:
block/curl.c:546 curl_close(21) info: redundant null check on s->url calling free()

The check was redundant, and free was also wrong because the memory
was allocated using g_strdup.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 block/curl.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Kevin Wolf Sept. 4, 2012, 2:11 p.m.
Am 01.09.2012 11:06, schrieb Stefan Weil:
> Report from smatch:
> block/curl.c:546 curl_close(21) info: redundant null check on s->url calling free()
> 
> The check was redundant, and free was also wrong because the memory
> was allocated using g_strdup.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>

Thanks, applied to block-next.

Kevin

Patch hide | download patch | download mbox

diff --git a/block/curl.c b/block/curl.c
index e7c3634..c1074cd 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -542,8 +542,7 @@  static void curl_close(BlockDriverState *bs)
     }
     if (s->multi)
         curl_multi_cleanup(s->multi);
-    if (s->url)
-        free(s->url);
+    g_free(s->url);
 }
 
 static int64_t curl_getlength(BlockDriverState *bs)