GUACAMOLE-424: Merge changes addressing potential NULL-pointer dereference in VNC user leave handler.
diff --git a/configure.ac b/configure.ac
index 8725748..e04d581 100644
--- a/configure.ac
+++ b/configure.ac
@@ -506,7 +506,6 @@
 
 have_freerdp=disabled
 RDP_LIBS=
-WINPR_LIBS=
 AC_ARG_WITH([rdp],
             [AS_HELP_STRING([--with-rdp],
                             [support RDP @<:@default=check@:>@])],
@@ -696,7 +695,7 @@
 # Check for stream support via WinPR
 if test "x${have_freerdp}" = "xyes"
 then
-    AC_CHECK_HEADER(winpr/stream.h,[WINPR_LIBS="$WINPR_LIBS -lwinpr-utils"],
+    AC_CHECK_HEADER(winpr/stream.h,,
                     [have_winpr=no,
                      AC_CHECK_DECL([stream_write_uint8],,
                                   [AC_MSG_WARN([
@@ -1016,7 +1015,6 @@
 AM_CONDITIONAL([ENABLE_RDP],   [test "x${have_freerdp}" = "xyes"])
 
 AC_SUBST(RDP_LIBS)
-AC_SUBST(WINPR_LIBS)
 
 #
 # libssh2
diff --git a/src/protocols/rdp/Makefile.am b/src/protocols/rdp/Makefile.am
index 826f22f..d26b78c 100644
--- a/src/protocols/rdp/Makefile.am
+++ b/src/protocols/rdp/Makefile.am
@@ -185,8 +185,7 @@
 guacai_ldflags =                   \
     -module -avoid-version -shared \
     @PTHREAD_LIBS@                 \
-    @RDP_LIBS@                     \
-    @WINPR_LIBS@
+    @RDP_LIBS@
 
 guacai_libadd =     \
     @COMMON_LTLIB@  \
@@ -251,11 +250,14 @@
     $(srcdir)/keymaps/base.keymap         \
     $(srcdir)/keymaps/failsafe.keymap     \
     $(srcdir)/keymaps/de_de_qwertz.keymap \
+    $(srcdir)/keymaps/en_gb_qwerty.keymap \
     $(srcdir)/keymaps/en_us_qwerty.keymap \
+    $(srcdir)/keymaps/es_es_qwerty.keymap \
     $(srcdir)/keymaps/fr_fr_azerty.keymap \
     $(srcdir)/keymaps/fr_ch_qwertz.keymap \
     $(srcdir)/keymaps/it_it_qwerty.keymap \
     $(srcdir)/keymaps/ja_jp_qwerty.keymap \
+    $(srcdir)/keymaps/pt_br_qwerty.keymap \
     $(srcdir)/keymaps/sv_se_qwerty.keymap
 
 _generated_keymaps.c: $(rdp_keymaps)
diff --git a/src/protocols/rdp/keymaps/en_gb_qwerty.keymap b/src/protocols/rdp/keymaps/en_gb_qwerty.keymap
new file mode 100644
index 0000000..92fe9de
--- /dev/null
+++ b/src/protocols/rdp/keymaps/en_gb_qwerty.keymap
@@ -0,0 +1,56 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+parent  "base"
+name    "en-gb-qwerty"
+freerdp "KBD_UNITED_KINGDOM"
+
+#
+# Basic keys
+#
+
+map -altgr -shift 0x29 0x02..0x0D      ~ "`1234567890-="
+map -altgr -shift      0x10..0x1B      ~ "qwertyuiop[]"
+map -altgr -shift      0x1E..0x28 0x2B ~ "asdfghjkl;'#"
+map -altgr -shift 0x56 0x2C..0x35      ~ "\zxcvbnm,./"
+
+map -altgr +shift 0x29 0x02..0x0D      ~ "¬!"£$%^&*()_+"
+map -altgr +shift      0x10..0x1B      ~ "QWERTYUIOP{}"
+map -altgr +shift      0x1E..0x28 0x2B ~ "ASDFGHJKL:@~"
+map -altgr +shift 0x56 0x2C..0x35      ~ "|ZXCVBNM<>?"
+
+#
+# Keys requiring AltGr
+#
+
+map +altgr -shift 0x29 ~ "¦"
+map +altgr -shift 0x05 ~ "€"
+map +altgr -shift 0x12 ~ "é"
+map +altgr +shift 0x12 ~ "É"
+map +altgr -shift 0x16 ~ "ú"
+map +altgr +shift 0x16 ~ "Ú"
+map +altgr -shift 0x17 ~ "í"
+map +altgr +shift 0x17 ~ "Í"
+map +altgr -shift 0x18 ~ "ó"
+map +altgr +shift 0x18 ~ "Ó"
+map +altgr -shift 0x1E ~ "á"
+map +altgr +shift 0x1E ~ "Á"
+map +altgr -shift 0x2E ~ "ç"
+map +altgr +shift 0x2E ~ "Ç"
+
diff --git a/src/protocols/rdp/keymaps/es_es_qwerty.keymap b/src/protocols/rdp/keymaps/es_es_qwerty.keymap
new file mode 100644
index 0000000..bd0f281
--- /dev/null
+++ b/src/protocols/rdp/keymaps/es_es_qwerty.keymap
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+parent  "base"
+name    "es-es-qwerty"
+freerdp "KBD_SPANISH"
+
+#
+# Basic keys
+#
+
+map -altgr -shift 0x29 0x02..0x0D      ~ "º1234567890'¡"
+map -altgr -shift      0x10..0x19 0x1B ~ "qwertyuiop+"
+map -altgr -shift      0x1E..0x27 0x2B ~ "asdfghjklñç"
+map -altgr -shift 0x56 0x2C..0x35      ~ "<zxcvbnm,.-"
+
+map -altgr +shift 0x29 0x02..0x0D      ~ "ª!"·$%&/()=?¿"
+map -altgr +shift      0x10..0x19 0x1B ~ "QWERTYUIOP*"
+map -altgr +shift      0x1E..0x27 0x2B ~ "ASDFGHJKLÑÇ"
+map -altgr +shift 0x56 0x2C..0x35      ~ ">ZXCVBNM;:_"
+
+#
+# Keys requiring AltGr
+#
+
+map +altgr -shift 0x29 0x02..0x04 0x07 ~ "\|@#¬"
+map +altgr -shift 0x12 0x1A 0x1B       ~ "€[]"
+map +altgr -shift 0x28 0x2B            ~ "{}"
+
+#
+# Dead keys
+#
+
+map -altgr -shift 0x1A ~ 0xFE50 # Dead grave
+map -altgr -shift 0x28 ~ 0xFE51 # Dead acute
+map -altgr +shift 0x1A ~ 0xFE52 # Dead circumflex
+map +altgr -shift 0x05 ~ 0xFE53 # Dead tilde
+map -altgr +shift 0x28 ~ 0xFE57 # Dead diaeresis (umlaut)
diff --git a/src/protocols/rdp/keymaps/pt_br_qwerty.keymap b/src/protocols/rdp/keymaps/pt_br_qwerty.keymap
new file mode 100644
index 0000000..54df313
--- /dev/null
+++ b/src/protocols/rdp/keymaps/pt_br_qwerty.keymap
@@ -0,0 +1,57 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+parent  "base"
+name    "pt-br-qwerty"
+freerdp "KBD_PORTUGUESE_BRAZILIAN_ABNT2"
+
+#
+# Basic keys
+#
+
+map -altgr -shift 0x29 0x02..0x0D      ~ "'1234567890-="
+map -altgr -shift      0x10..0x19 0x1B ~ "qwertyuiop["
+map -altgr -shift      0x1E..0x27 0x2B ~ "asdfghjklç]"
+map -altgr -shift 0x56 0x2C..0x36      ~ "\zxcvbnm,.;/"
+
+map -altgr +shift 0x29 0x02..0x06 0x08..0x0D ~ ""!@#$%&*()_+"
+map -altgr +shift      0x10..0x19 0x1B       ~ "QWERTYUIOP{"
+map -altgr +shift      0x1E..0x27 0x2B       ~ "ASDFGHJKLÇ}"
+map -altgr +shift 0x56 0x2C..0x36            ~ "|ZXCVBNM<>:?"
+
+#
+# Keys requiring AltGr
+#
+
+map +altgr -shift 0x02..0x07 0x0D ~ "¹²³£¢¬§"
+map +altgr -shift 0x10..0x11 ~ "/?"
+map +altgr -shift 0x12 ~ "°"
+map +altgr -shift 0x1B ~ "ª"
+map +altgr -shift 0x2B ~ "º"
+map +altgr -shift 0x2E ~ "₢"
+
+#
+# Dead keys
+#
+
+map -altgr +shift 0x07 ~ 0xFE57 # Dead diaeresis (umlaut)
+map -altgr +shift 0x1A ~ 0xFE50 # Dead grave
+map -altgr -shift 0x1A ~ 0xFE51 # Dead acute
+map -altgr +shift 0x28 ~ 0xFE52 # Dead circumflex
+map -altgr -shift 0x28 ~ 0xFE53 # Dead tilde