Does anyone know why the following code causes me a memory leak:

HGLOBAL hGlobal = GlobalAlloc( GMEM_FIXED, aJpegSize );
void* p = GlobalLock(hGlobal);
memcpy((char *)p,imageptr,aJpegSize);	
IStream* pStream = NULL;

if ( CreateStreamOnHGlobal( hGlobal, TRUE, &pStream ) == S_OK);
				if ( aPicture == NULL )
					delete aPicture;
				aPicture = Image::FromStream(pStream,0); 	

<< moderator edit: added [code][/code] tags >>

NOTE: the imageptr is a pointer to my jpeg image, and aJpegSize is the size of the image. I later go on to do:

Graphics graphics( dc );
graphics.DrawImage( w->aPicture,  0, 0, 320, 240 );

I'm really stuck, any idea could help!
Thanks in advance,

Found my own answer:::::::

For those interested,,,,, the pointer aPicture ( which is of type Image ) must be delete at some point, or else it never call the destructor, which in tern never deallocates its memory.

Therefore I now have this somewhere in my code:

if ( w->aPicture != NULL )
delete w->aPicture; // Relese the memory allocated by aPicture
w->aPicture = 0;


"What does'nt kill you, makes you stronger"