A cautionary tale
So what went wrong with such a simple patch? The fix for the memory leak looks correct – and it is. The problem is the [untouched] line above it.
No confidence can be placed in code that has not been run. Even simple changes have more implications than you can possibly comprehend.