I get really strange color output when I use tonemap with EXR files, its like perfect for most of the image but some places of the image end up having large yellow or red spots.

Code :
ILuint iid;
	ilGenImages(1, &iid);
	ilBindImage(iid);
 
	auto conv = s2w(_filename);
	if(!ilLoadImage(conv.c_str()))
	{
		std::stringstream wss; wss << L"Failed to load texture: " << _filename << L" Error#" << ilGetError();
		auto err = wss.str();
		LOG(WARNING) << err;
		return false;
	}
 
	iluImageParameter(ILU_FILTER, ILU_BILINEAR);
 
	//Effects
    /*iluAlienify();
	iluBlurAvg(10);
	iluBlurGaussian(10);
	iluContrast(1.7f);
	iluEqualize();
	iluGammaCorrect(0.7f);
	iluNegative();
	iluNoisify(0.8f);
	iluPixelize(20);
	iluSharpen(2.1f, 3.0f);
	iluSharpen(1.5f, 1.5f);*/
 
	data.width	= ilGetInteger(IL_IMAGE_WIDTH);
	data.height	= ilGetInteger(IL_IMAGE_HEIGHT);
 
	unsigned int size;
	if(HDR)size = data.width * data.height * 16;
	else size = data.width * data.height * 4; 
 
	data.data = new unsigned char[size];
	ilCopyPixels(0, 0, 0, data.width, data.height, 1, IL_RGBA, HDR ? IL_FLOAT : IL_UNSIGNED_BYTE, data.data);
	ilDeleteImage(iid);
 
glGenTextures(1, &amp;id);
		glBindTexture(GL_TEXTURE_2D, id);
 
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);			
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
 
		if(strstr((char*)glGetString(GL_EXTENSIONS), "GL_EXT_texture_filter_anisotropic"))
		{
			float maximumaf = 0.0f;
			glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &amp;maximumaf);
			if(gOptions->af > maximumaf)gOptions->af = static_cast<int>(maximumaf);
			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, static_cast<float>(gOptions->af));
		}
 
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
		iluImageParameter(ILU_FILTER, ILU_BILINEAR);
 
		gluBuild2DMipmaps(GL_TEXTURE_2D, HDR ? GL_RGBA32F : GL_RGBA, data.width, data.height, GL_RGBA, HDR ? GL_FLOAT : GL_UNSIGNED_BYTE, data.data);
 
		if(data.data)
		{
			delete[] data.data;
			data.data = nullptr;
		}

Can someone please tell me what could be wrong?