miniupnp
miniupnp copied to clipboard
miniupnpd: potential dereference of NULL ; potential double free ; missing fclose
This fixes three Xcode analyser warnings.
- The first one is trivial: a missing fclose on each early return.
The other two are more tricky and depends if ary_options is NULL or not.
-
If
ary_optionsis not null, then there is a double free: once onfree(ary_options)then again onrealloc(ary_options, ...). Since we want an optimal realloc, we don't want to prematurely add someary_options = NULLright after free. Consequently, it's best to remove thefree. -
If
ary_optionsis NULL already, then the analyser is confused by a false positive wherenum_optionswould be non-zero at the start of the loop. To resolve that, we can setnum_optionsto zero unconditionally.
ping @miniupnp