Fixed invalid reallocations

I ran into a crash when I tried to redirect all 32 COM ports my machine has. Reallocs were not accounting the size of array element and effectively shrinked those arrays instead of enlarging them. This results in a memory corruption and eventual segfault.