[vlc-devel] commit: Fix an actual error path for realloc() that doesn't leak in rtsp/ real.c (JP Dinger )

jpd at videolan.org jpd at videolan.org
Tue Jul 14 14:38:03 CEST 2009


On Tue, Jul 14, 2009 at 02:24:10PM +0200, R??mi Denis-Courmont wrote:
> Well as much as we can work around realloc() -unlikely- shrinking failure,
> we cannot work around -more likely- expansion failures in a generic way.
> Since a realloc() wrapper would not know the current size of the
> allocation, I fail to see any use thereof.

In the limited case where an existing buffer is simply re-used (as in
the real.c case and the setup parts of the live555 support) one can
check for NULL and bail out accordingly, and then this approach prevents
a memory leak. It's not as much graceful degradation as realloc could
perhaps do exactly because that's hard to impossible to do well with
this interface. But at least it provides safe and non-leaky error paths
for some of the contested realloc()s that currently are not tested at
all.

Think about it and you'll see.




More information about the vlc-devel mailing list