Fix realloc

Issue #334