Check for strings before attempting to xfree them#991
Check for strings before attempting to xfree them#991djberg96 wants to merge 1 commit intolibgit2:masterfrom
Conversation
|
@carlosmn Look ok? |
|
Anyone home? |
|
Are you sure calling Now, if we end up mixing up something like |
|
What I'm noticing now is that we are calling the wrong free function completely, and causing memory leaks. Rugged should always be using the ruby allocator but if we don't end up doing that, On top of that, we should be using |
|
Indeed, my original PR was superficial. I'm working on updating it... |
The
rugged_rb_ary_to_strarrayfunction usesxmallocto allocate memory forstr_array->strings, but there are several cases where this memory might not be allocated:If
rb_arrayisNIL_P, the function returns early withstrings = NULL. If there's an empty array, the count would be 0. However, in the cleanup sections, the code unconditionally callsxfree(custom_headers.strings)without checking if it's NULL. This can cause "munmap_chunk(): invalid pointer" errors.Should fix #859