Make sure we check failed memory allocations
diff --git a/unix/vncconfig/vncconfig.cxx b/unix/vncconfig/vncconfig.cxx
index f70cc71..bffdfbe 100644
--- a/unix/vncconfig/vncconfig.cxx
+++ b/unix/vncconfig/vncconfig.cxx
@@ -215,6 +215,10 @@
       if (cutText)
         XFree(cutText);
       cutText = (char*)malloc(nitems); // assuming XFree() same as free()
+      if (!cutText) {
+        vlog.error("unable to allocate selection buffer");
+        return;
+      }
       memcpy(cutText, data, nitems);
       cutTextLen = nitems;
       vlog.debug("sending %s selection as server cut text: '%.*s%s'",