GUACAMOLE-935: Merge fix for differing rdpBitmap free behavior.

diff --git a/configure.ac b/configure.ac
index 24c1588..0ec57aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -578,6 +578,30 @@
 
 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_EGREP_CPP([\"2\\.0\\.0-dev\"], [
+
+        #include <freerdp/version.h>
+        FREERDP_VERSION_FULL
+
+    ],
+    [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])])
+
+fi
+
 # Glyph callback variants
 if test "x${have_freerdp2}" = "xyes"
 then
diff --git a/src/protocols/rdp/bitmap.c b/src/protocols/rdp/bitmap.c
index db29316..ac4d979 100644
--- a/src/protocols/rdp/bitmap.c
+++ b/src/protocols/rdp/bitmap.c
@@ -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 @@
     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
 
 }