Fix crashes occurring when XDestroyImage() tries to free image data.

XDestroyImage() assumes that it can call free() on the data pointed to
by the XImage structure it is passed.  However, the data may have come
from the strange malloc(), in which case calling free() on it is a
guaranteed crash.  Unfortunately, we have no way of knowing here if
this is the case or not, so we must always set gdisp->gg.img->data and
gdisp->gg.mask->data to NULL and live with the resulting memory leak
when we are wrong.
Merge branch 'master' into HEAD
Call free() on gg.img->data and gg.mask->data before setting to NULL.

In the case where malloc() is really GC_malloc(), setting the pointer
to NULL is necessary to avoid a crash.  In that case, free() will
really be GC_free(), and calling it beforehand causes no harm.  In the
case where malloc() is really libc malloc(), free() will really be
libc free(), and calling it before setting the pointer to NULL avoids
a memory leaks.

In all cases, this will ensure that the data pointer is passed to the
free() function corresponding to the malloc() that produced it.
Added explanatory comments to image data pointer cleanup.

Explain the reason for freeing and setting to NULL the image data
pointer before calling XDestroyImage(), so that the code can be
identified and removed as appropriate.
Merge pull request #1319 from blipvert/fixes/36

Fix crashes occurring when XDestroyImage() tries to free image data.