Fix possible inifinite allocation loop