Fixed invalid reallocations
Merge pull request #1451 from ilammy/realloc-fixes

Fixed invalid reallocations