Fix _aligned_realloc() when resizing to smaller size

Fix issue #1952 affecting the current master, causing crashes on GDI bitmap updates.