Commit 2cf93647 authored by Vasil Velichkov's avatar Vasil Velichkov

Do not copy the memory when the buffer is empty

This fixes the following undefined behaviour

converter-example.c:721:13: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
parent d3df38d8
......@@ -717,9 +717,11 @@ static void add_bytes_to_buffer(const void *data2add, size_t bytes) {
perror("malloc()");
exit(EX_OSERR);
}
if (DynamicBuffer.length) {
memcpy(p,
DynamicBuffer.data + DynamicBuffer.offset,
DynamicBuffer.length);
}
FREEMEM(DynamicBuffer.data);
DynamicBuffer.data = (uint8_t *)p;
DynamicBuffer.offset = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment