Fix mismatching allocation and deallocation

Fixes ticket #10374

Signed-off-by: Philippe Saint-Pierre <stpere@gmail.com>