]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CONTRIB: da: fix memory leak in dummy function da_atlas_open()
authorWilly Tarreau <w@1wt.eu>
Sun, 12 Jul 2020 07:12:07 +0000 (09:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 12 Jul 2020 07:12:07 +0000 (09:12 +0200)
The dummy function takes care of doing a bit of work using a malloc()
to avoid returning a constant but it doesn't free the tested pointer,
which coverity noticed in issue #741. Let's free it before testing it
for the return value.

This may be backported but is not important since this code is only
present to allow to build the device detection code and not to actually
run it.

contrib/deviceatlas/dac.c

index f94fe8daf59ece2d00b8579b8d4cedf5bede264a..720dc6af4d39ccabfc602fa57edf2680d61744d1 100644 (file)
@@ -63,8 +63,9 @@ da_atlas_compile(void *ctx, da_read_fn readfn, da_setpos_fn rewind, void **ptr,
 da_status_t
 da_atlas_open(da_atlas_t *atlas, da_property_decl_t *extraprops, const void *ptr, size_t len)
 {
-    ptr = malloc(len);
-    return ptr ? DA_OK : DA_NOMEM;
+    void *ptr2 = malloc(len);
+    free(ptr2);
+    return ptr2 ? DA_OK : DA_NOMEM;
 }
 
 void