rugged icon indicating copy to clipboard operation
rugged copied to clipboard

Check for strings before attempting to xfree them

Open djberg96 opened this issue 5 months ago • 1 comments

The rugged_rb_ary_to_strarray function uses xmalloc to allocate memory for str_array->strings, but there are several cases where this memory might not be allocated:

If rb_array is NIL_P, the function returns early with strings = NULL. If there's an empty array, the count would be 0. However, in the cleanup sections, the code unconditionally calls xfree(custom_headers.strings) without checking if it's NULL. This can cause "munmap_chunk(): invalid pointer" errors.

Should fix https://github.com/libgit2/rugged/issues/859

djberg96 avatar Sep 08 '25 17:09 djberg96

@carlosmn Look ok?

djberg96 avatar Sep 27 '25 23:09 djberg96