Fix double free() bug
Fix preallocate(0) bug