FreeImage delete[] bitmap data fails-Collection of common programming errors

Please help me with cleaning up my heap after loading bitmap with FreeImage. Somehow delete[] data; causes _ASSERTE(_CrtIsValidHeapPointer(pUserData)) assertion, and I cannot found how to fix it other than commenting this line. Will there memory leak? Any help and explanation will be appreciated!

Full code at pastebin: http://pastebin.com/dWxz0tjM

Visual Studio 2012 solution (with huge FreeImage static lib): http://rghost.ru/40322357 (15.7 Mbytes!)

Full code here:

#include 

// FreeImage static linkage
#define  FREEIMAGE_LIB
#include "FreeImage/FreeImage.h"
#include "FreeImage/Utilities.h"
#pragma comment(lib, "FreeImage/FreeImaged.lib")

using namespace std;

static const wchar_t* sk_Filename = L"Test.tga";

// Error handler to use in callback
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *msg) 
{
    char buf[1024];
    sprintf_s(buf, 1024, "Error: %s", FreeImage_GetFormatFromFIF(fif));

    cout