I trust you enough to be sure that __this comment is kind of useless__, but since I have a doubt I will just ask the question: `nullptr` is a C++ specific _object_, whereas you are using the `realloc` function which is C specific. Are you sure the two are compatibles? Probably just a `(void *) 0` would make the job.
I took a quick look on StackOverflow (didn't go deep into details though) and it seems like there's a bit of confusion over this, especially when mixing C allocations with C++ functions.