Fix memory-bug detected by address-sanitizer

Enabled compilation with address-sanitizer,
fixed 1 bug it detected.