aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/rfb/SMsgWriter.cxx1
-rw-r--r--common/rfb/UpdateTracker.cxx2
-rw-r--r--common/rfb/tightDecode.h1
-rw-r--r--unix/vncconfig/vncExt.c20
-rw-r--r--unix/vncconfig/vncconfig.cxx4
-rw-r--r--vncviewer/OSXPixelBuffer.cxx11
-rw-r--r--vncviewer/Viewport.cxx3
-rw-r--r--vncviewer/Win32PixelBuffer.cxx1
-rw-r--r--vncviewer/X11PixelBuffer.cxx13
9 files changed, 38 insertions, 18 deletions
diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx
index 3698cb6c..0d61292c 100644
--- a/common/rfb/SMsgWriter.cxx
+++ b/common/rfb/SMsgWriter.cxx
@@ -18,7 +18,6 @@
* USA.
*/
#include <stdio.h>
-#include <assert.h>
#include <rdr/OutStream.h>
#include <rfb/msgTypes.h>
#include <rfb/fenceTypes.h>
diff --git a/common/rfb/UpdateTracker.cxx b/common/rfb/UpdateTracker.cxx
index 14ac49d7..b53b8509 100644
--- a/common/rfb/UpdateTracker.cxx
+++ b/common/rfb/UpdateTracker.cxx
@@ -21,8 +21,6 @@
// Tracks updated regions and a region-copy event, too
//
-#include <assert.h>
-
#include <rfb/UpdateTracker.h>
#include <rfb/LogWriter.h>
diff --git a/common/rfb/tightDecode.h b/common/rfb/tightDecode.h
index 0089f453..fe18ce86 100644
--- a/common/rfb/tightDecode.h
+++ b/common/rfb/tightDecode.h
@@ -28,7 +28,6 @@
#include <rdr/ZlibInStream.h>
#include <rfb/Exception.h>
#include <rfb/TightConstants.h>
-#include <assert.h>
namespace rfb {
diff --git a/unix/vncconfig/vncExt.c b/unix/vncconfig/vncExt.c
index ff5532bf..c2e6d3c1 100644
--- a/unix/vncconfig/vncExt.c
+++ b/unix/vncconfig/vncExt.c
@@ -109,6 +109,10 @@ Bool XVncExtGetParam(Display* dpy, const char* param, char** value, int* len)
if (rep.success) {
*len = rep.valueLen;
*value = (char*) Xmalloc (*len+1);
+ if (!*value) {
+ _XEatData(dpy, (*len+1)&~1);
+ return False;
+ }
_XReadPad(dpy, *value, *len);
(*value)[*len] = 0;
}
@@ -141,6 +145,10 @@ char* XVncExtGetParamDesc(Display* dpy, const char* param)
}
if (rep.success) {
desc = (char*)Xmalloc(rep.descLen+1);
+ if (!*desc) {
+ _XEatData(dpy, (rep.descLen+1)&~1);
+ return False;
+ }
_XReadPad(dpy, desc, rep.descLen);
desc[rep.descLen] = 0;
}
@@ -243,6 +251,10 @@ Bool XVncExtGetClientCutText(Display* dpy, char** str, int* len)
SyncHandle();
*len = rep.textLen;
*str = (char*) Xmalloc (*len+1);
+ if (!*str) {
+ _XEatData(dpy, (*len+1)&~1);
+ return False;
+ }
_XReadPad(dpy, *str, *len);
(*str)[*len] = 0;
return True;
@@ -312,9 +324,15 @@ Bool XVncExtGetQueryConnect(Display* dpy, char** addr, char** user,
SyncHandle();
*addr = Xmalloc(rep.addrLen+1);
+ *user = Xmalloc(rep.userLen+1);
+ if (!*addr || !*user) {
+ Xfree(*addr);
+ Xfree(*user);
+ _XEatData(dpy, (rep.addrLen+1)&~1 + (rep.userLen+1)&~1);
+ return False;
+ }
_XReadPad(dpy, *addr, rep.addrLen);
(*addr)[rep.addrLen] = 0;
- *user = Xmalloc(rep.userLen+1);
_XReadPad(dpy, *user, rep.userLen);
(*user)[rep.userLen] = 0;
*timeout = rep.timeout;
diff --git a/unix/vncconfig/vncconfig.cxx b/unix/vncconfig/vncconfig.cxx
index f70cc714..bffdfbe2 100644
--- a/unix/vncconfig/vncconfig.cxx
+++ b/unix/vncconfig/vncconfig.cxx
@@ -215,6 +215,10 @@ public:
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'",
diff --git a/vncviewer/OSXPixelBuffer.cxx b/vncviewer/OSXPixelBuffer.cxx
index df82c86f..e9100f27 100644
--- a/vncviewer/OSXPixelBuffer.cxx
+++ b/vncviewer/OSXPixelBuffer.cxx
@@ -20,8 +20,6 @@
#include <config.h>
#endif
-#include <assert.h>
-
#include <ApplicationServices/ApplicationServices.h>
#include <FL/Fl_Window.H>
@@ -47,16 +45,17 @@ OSXPixelBuffer::OSXPixelBuffer(int width, int height) :
data = new rdr::U8[width * height * format.bpp/8];
if (data == NULL)
- throw rfb::Exception(_("Error: Not enough memory for framebuffer"));
+ throw rfb::Exception(_("Not enough memory for framebuffer"));
lut = CGColorSpaceCreateDeviceRGB();
- assert(lut);
+ if (!lut)
+ throw rfb::Exception(_("Could not create framebuffer device"));
bitmap = CGBitmapContextCreate(data, width, height, 8, width*4, lut,
kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little);
- assert(bitmap);
-
CGColorSpaceRelease(lut);
+ if (!bitmap)
+ throw rfb::Exception(_("Could not create framebuffer bitmap"));
}
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 66a78412..4daff164 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -27,6 +27,7 @@
#include <rfb/CMsgWriter.h>
#include <rfb/LogWriter.h>
+#include <rfb/Exception.h>
// FLTK can pull in the X11 headers on some systems
#ifndef XK_VoidSymbol
@@ -452,6 +453,8 @@ PlatformPixelBuffer* Viewport::createFramebuffer(int w, int h)
fb = new X11PixelBuffer(w, h);
#endif
} catch (rdr::Exception& e) {
+ vlog.error(_("Unable to create platform specific framebuffer: %s"), e.str());
+ vlog.error(_("Using platform independent framebuffer"));
fb = new FLTKPixelBuffer(w, h);
}
diff --git a/vncviewer/Win32PixelBuffer.cxx b/vncviewer/Win32PixelBuffer.cxx
index 48718165..3f825304 100644
--- a/vncviewer/Win32PixelBuffer.cxx
+++ b/vncviewer/Win32PixelBuffer.cxx
@@ -21,7 +21,6 @@
#include <config.h>
#endif
-#include <assert.h>
#include <stdlib.h>
#include <windows.h>
diff --git a/vncviewer/X11PixelBuffer.cxx b/vncviewer/X11PixelBuffer.cxx
index b729e800..59b90e2c 100644
--- a/vncviewer/X11PixelBuffer.cxx
+++ b/vncviewer/X11PixelBuffer.cxx
@@ -21,7 +21,6 @@
#include <config.h>
#endif
-#include <assert.h>
#include <stdlib.h>
#include <FL/x.H>
@@ -57,7 +56,7 @@ static PixelFormat display_pf()
if (format[i].depth == fl_visual->depth) break;
if (i == nformats)
- throw rfb::Exception(_("Error: display lacks pixmap format for default depth"));
+ throw rfb::Exception(_("Display lacks pixmap format for default depth"));
switch (format[i].bits_per_pixel) {
case 8:
@@ -66,7 +65,7 @@ static PixelFormat display_pf()
bpp = format[i].bits_per_pixel;
break;
default:
- throw rfb::Exception(_("Error: couldn't find suitable pixmap format"));
+ throw rfb::Exception(_("Couldn't find suitable pixmap format"));
}
XFree(format);
@@ -75,7 +74,7 @@ static PixelFormat display_pf()
trueColour = (fl_visual->c_class == TrueColor);
if (!trueColour)
- throw rfb::Exception(_("Error: only true colour displays supported"));
+ throw rfb::Exception(_("Only true colour displays supported"));
vlog.info(_("Using default colormap and visual, %sdepth %d."),
(fl_visual->c_class == TrueColor) ? "TrueColor, " :
@@ -104,10 +103,12 @@ X11PixelBuffer::X11PixelBuffer(int width, int height) :
if (!setupShm()) {
xim = XCreateImage(fl_display, fl_visual->visual, fl_visual->depth,
ZPixmap, 0, 0, width, height, BitmapPad(fl_display), 0);
- assert(xim);
+ if (!xim)
+ throw rfb::Exception(_("Could not create framebuffer image"));
xim->data = (char*)malloc(xim->bytes_per_line * xim->height);
- assert(xim->data);
+ if (!xim->data)
+ throw rfb::Exception(_("Not enough memory for framebuffer"));
}
data = (rdr::U8*)xim->data;