GUACAMOLE-935: Free internals of rdpBitmap only when required.
In FreeRDP 2.0.0-rc0 and earlier, Bitmap_Free(bitmap) invokes the free
handler of the given bitmap, frees bitmap->data, and then frees the
bitmap. The implementation-specific free handler needs to be aware only
of the implementation's own concerns.
After FreeRDP 2.0.0-rc0, Bitmap_Free(bitmap) only invokes the
implementation-specific free handler, and it's on the implementation to
know that bitmap->data must be manually freed with _aligned_free() and
bitmap must be freed with free(). The implementation-specific free
handler must be aware of the internals of the library.
See commit 8dda26a
.
This commit is contained in:
parent
0cd9ba387b
commit
26dfc533bd
31
configure.ac
31
configure.ac
@ -578,6 +578,37 @@ then
|
||||
|
||||
fi
|
||||
|
||||
# Variation in memory internal allocation/free behavior
|
||||
if test "x${have_freerdp2}" = "xyes"
|
||||
then
|
||||
|
||||
# FreeRDP 2.0.0-rc0 and older automatically free rdpBitmap and its
|
||||
# associated data member within Bitmap_Free(), relying on the
|
||||
# implementation-specific free handler to free only implementation-specific
|
||||
# data. This changed in commit 2cf10cc, and implementations must now
|
||||
# manually free all data associated with the rdpBitmap, even data which
|
||||
# was not allocated by the implementation.
|
||||
AC_MSG_CHECKING([whether Bitmap_Free() frees the rdpBitmap and its image data])
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
|
||||
#include <freerdp/version.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
/* Return successfully if version is 2.0.0-rc0 */
|
||||
return strcmp(FREERDP_VERSION_FULL, "2.0.0-dev");
|
||||
}
|
||||
|
||||
]])],
|
||||
[AC_MSG_RESULT([yes])]
|
||||
[AC_DEFINE([FREERDP_BITMAP_FREE_FREES_BITMAP],,
|
||||
[Whether Bitmap_Free() frees the rdpBitmap and its image data])],
|
||||
[AC_MSG_RESULT([no])],
|
||||
[AC_MSG_RESULT([assuming no (cross-compiling)])])
|
||||
|
||||
fi
|
||||
|
||||
# Glyph callback variants
|
||||
if test "x${have_freerdp2}" = "xyes"
|
||||
then
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "bitmap.h"
|
||||
#include "common/display.h"
|
||||
#include "common/surface.h"
|
||||
#include "config.h"
|
||||
#include "rdp.h"
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
@ -127,12 +128,14 @@ void guac_rdp_bitmap_free(rdpContext* context, rdpBitmap* bitmap) {
|
||||
if (buffer != NULL)
|
||||
guac_common_display_free_buffer(rdp_client->display, buffer);
|
||||
|
||||
/* NOTE: FreeRDP-allocated memory for the rdpBitmap will NOT be
|
||||
* automatically released after this free handler is invoked, thus we must
|
||||
* do so manually here */
|
||||
#ifndef FREERDP_BITMAP_FREE_FREES_BITMAP
|
||||
/* NOTE: Except in FreeRDP 2.0.0-rc0 and earlier, FreeRDP-allocated memory
|
||||
* for the rdpBitmap will NOT be automatically released after this free
|
||||
* handler is invoked, thus we must do so manually here */
|
||||
|
||||
_aligned_free(bitmap->data);
|
||||
free(bitmap);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user