Double allocation of pixel data when using SDL_CreateRGBSurf

It’s not responsible. It’s responsible for freeing it’s own HBITMAP but CreateDIBSection overwrites the pixels with it’s own allocation and the original is lost.
Anyway for anyone else having this problem workaround is pretty simple.
Just store surface->pixels pointer in some temporary variable and let the CreateDIBSection allocate over it.
When you are releasing the surfaces. First DeleteObject(bitmap) and then surface->pixels = temp after which you can normally release surface with SDL_FreeSurface.

Like Matthew said, you can probably do it with providing hSection variable of CreateFileMapping created mappingObject, but I avoided this route because CreateFileMapping on my computer does BSOD every time I use it so I ended up doing this little hack.