Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for n_targets==0 in finish_merged_header() shrinking
The realloc() function might return NULL when asked to resize to zero bytes. It is near impossible to correctly distinguish NULL-as-resize-0 (incoming ptr freed) and NULL-as-realloc-failed (incoming ptr not freed): see WG14 defect report 400 and Austin Group issues 400, 526, and 688. Avoid all this by simply setting target_name and target_len to NULL when n_targets==0, leaving merged_hdr->target_name/len to be freed later by free_merged_header(). Fixes #495. Hat tip to @daviesrob for identifying the cause.
- Loading branch information