[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] code smell (IntelliSense C6308): realloc could cause a memory leak (#335)

tim Rowledge tim at rowledge.org
Wed Jan 2 01:04:17 UTC 2019



> On 2019-01-01, at 1:39 PM, Nicolas Cellier <notifications at github.com> wrote:
> 
> In this pattern:
> 
> ptr = realloc( ptr , new_size );
> 
> realloc may fail when HEAP memory is exhausted, then return 0, and overwrite ptr with a NULL pointer...
> But realloc did not free(ptr), it rather leaves it untouched!

That's just... awful. If it can't realloc it should damn well leave the original alone


tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Useful random insult:- Not much to show for four billion years of evolution.




More information about the Vm-dev mailing list