(ITS#8487) Properly handle realloc() failures