I am getting a memleak error here https://github.com/thesofproject/rimage/blob/main/src/ext_manifest.c#L134. (snippet below for history) on variable buffer. But as you can see, the buffer is passed back through the double pointer argument.
rimage/src/ext_manifest.c:134:2: error: Memory leak: buffer [memleak] return ret;
^
static int ext_man_build(const struct module module, struct ext_man_header dst_buff) { ... / alloc buffer for ext_man */ buffer = calloc(1, ext_man.full_size); if (!buffer) { ret = -ENOMEM; goto out; }
/ fill buffer with ext_man and section content / memcpy(buffer, &ext_man, ext_man.header_size); offset = ext_man.header_size;
memcpy(&buffer[offset], sec_buffer, section->size);
dst_buff = (struct ext_man_header )buffer;
out: free(sec_buffer); return ret; }
Could you provide a self-contained example? The file without headers is clean with 2.4.1.
I can reproduce with 2.3, but not 2.4. This was fixed in https://trac.cppcheck.net/ticket/10186.
Log in to post a comment.
I am getting a memleak error here
https://github.com/thesofproject/rimage/blob/main/src/ext_manifest.c#L134.
(snippet below for history) on variable buffer. But as you can see, the
buffer is passed back through the double pointer argument.
rimage/src/ext_manifest.c:134:2: error: Memory leak: buffer [memleak]
return ret;
^
static int ext_man_build(const struct module module,
struct ext_man_header dst_buff)
{
...
/ alloc buffer for ext_man */
buffer = calloc(1, ext_man.full_size);
if (!buffer) {
ret = -ENOMEM;
goto out;
}
/ fill buffer with ext_man and section content /
memcpy(buffer, &ext_man, ext_man.header_size);
offset = ext_man.header_size;
memcpy(&buffer[offset], sec_buffer, section->size);
dst_buff = (struct ext_man_header )buffer;
out:
free(sec_buffer);
return ret;
}
Could you provide a self-contained example? The file without headers is clean with 2.4.1.
I can reproduce with 2.3, but not 2.4. This was fixed in https://trac.cppcheck.net/ticket/10186.