summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorChristian Beier <dontmind@freeshell.org>2011-03-17 13:11:59 +0100
committerChristian Beier <dontmind@freeshell.org>2011-03-17 13:11:59 +0100
commitbf2470cec69ab00f7213aa136f5a2d486c9da17a (patch)
tree9ff1c77459eabd1ef1fc594c190cbb455c92a0bd /test
parent6b60690a4a1642c77bd6ac42789c4da6ed770075 (diff)
downloadlibtdevnc-bf2470cec69ab00f7213aa136f5a2d486c9da17a.tar.gz
libtdevnc-bf2470cec69ab00f7213aa136f5a2d486c9da17a.zip
Check rfbGetScreen() return value everywhere.
This fixes a segfault when a server is invoked with the '-help' commandline argument.
Diffstat (limited to 'test')
-rw-r--r--test/cargstest.c3
-rw-r--r--test/copyrecttest.c2
-rw-r--r--test/cursortest.c6
-rw-r--r--test/encodingstest.c2
4 files changed, 11 insertions, 2 deletions
diff --git a/test/cargstest.c b/test/cargstest.c
index 263982d..e2b97ee 100644
--- a/test/cargstest.c
+++ b/test/cargstest.c
@@ -10,6 +10,9 @@ int main(int argc,char** argv)
rfbBool ret=0;
screen = rfbGetScreen(&fake_argc,fake_argv,1024,768,8,3,1);
+ if(!screen)
+ return 0;
+
#define CHECK(a,b) if(screen->a!=b) { fprintf(stderr,#a " is %d (should be " #b ")\n",screen->a); ret=1; }
CHECK(width,1024);
CHECK(height,768);
diff --git a/test/copyrecttest.c b/test/copyrecttest.c
index 5521595..cd2a504 100644
--- a/test/copyrecttest.c
+++ b/test/copyrecttest.c
@@ -22,6 +22,8 @@ int main(int argc,char** argv)
double r,phi=0;
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,width,height,8,3,4);
+ if(!server)
+ return 0;
server->frameBuffer=(char*)malloc(width*height*4);
initBackground(server);
server->deferUpdateTime=0;
diff --git a/test/cursortest.c b/test/cursortest.c
index 7a4efd3..78c37e3 100644
--- a/test/cursortest.c
+++ b/test/cursortest.c
@@ -322,8 +322,10 @@ static void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
int main(int argc,char** argv)
{
- rfbScreenInfoPtr rfbScreen =
- rfbGetScreen(&argc,argv,maxx,maxy,8,3,bpp);
+ rfbScreenInfoPtr rfbScreen = rfbGetScreen(&argc,argv,maxx,maxy,8,3,bpp);
+ if(!rfbScreen)
+ return 0;
+
rfbScreen->desktopName = "Cursor Test";
rfbScreen->frameBuffer = (char*)malloc(maxx*maxy*bpp);
rfbScreen->ptrAddEvent = doptr;
diff --git a/test/encodingstest.c b/test/encodingstest.c
index bef30a8..6d2f04d 100644
--- a/test/encodingstest.c
+++ b/test/encodingstest.c
@@ -298,6 +298,8 @@ int main(int argc,char** argv)
/* Initialize server */
server=rfbGetScreen(&argc,argv,width,height,8,3,4);
+ if(!server)
+ return 0;
server->frameBuffer=malloc(400*300*4);
server->cursor=NULL;