fix size issue in the realloc call