On Wed, Mar 27, 2019 at 6:04 PM Yordan Karadzhov <ykaradzhov@xxxxxxxxxx> wrote: <snip> > + if (offset_array) > + free(offset_array); This should be free(*offset_array); and ditto for the rest. Also in the very unlikely event of malloc() failing, if the caller didn't initialize the arguments before calling, this will be calling free() with garbage. If we're paranoid for this case, we can either 1) have NULL initialized local variables where we malloc() and on failure free(), or on success assign to the output arguments 2) have a separate label for each malloc() failure case and jump to the correct label when malloc() fails -- Slavi