[REM3-186] Prevent buffer double-freeing in certain cases