cvReleaseImage throws exception
I created an image by capturing camera simple:
IplImage *img;
CvCapture *capture = cvCreateCameraCapture(0);
CvSize size = cvSize(1920, 1080);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH , size.width);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT , size.height);
img = cvQueryFrame(capture);
cvNamedWindow("VideoTest", CV_WINDOW_AUTOSIZE);
cvShowImage("VideoTest", img);
cvReleaseImage(&img);
The problem is cvReleaseImage throws a memory exception. It cannot deallocate memory for image. How can I fix it?