summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--VisualNaCro/nacro.c2
-rw-r--r--examples/backchannel.c2
-rw-r--r--examples/camera.c2
-rw-r--r--examples/colourmaptest.c3
-rw-r--r--examples/example.c5
-rw-r--r--examples/filetransfer.c2
-rw-r--r--examples/fontsel.c3
-rw-r--r--examples/mac.c2
-rw-r--r--examples/pnmshow.c2
-rw-r--r--examples/pnmshow24.c2
-rw-r--r--examples/simple.c2
-rw-r--r--examples/simple15.c3
-rw-r--r--examples/vncev.c2
-rw-r--r--examples/zippy.c2
-rw-r--r--test/cargstest.c3
-rw-r--r--test/copyrecttest.c2
-rw-r--r--test/cursortest.c6
-rw-r--r--test/encodingstest.c2
18 files changed, 41 insertions, 6 deletions
diff --git a/VisualNaCro/nacro.c b/VisualNaCro/nacro.c
index 2fc9e36..9c492b0 100644
--- a/VisualNaCro/nacro.c
+++ b/VisualNaCro/nacro.c
@@ -121,6 +121,8 @@ static rfbBool malloc_frame_buffer(rfbClient* cl)
res->client->frameBuffer=malloc(w*4*h);
res->server=rfbGetScreen(NULL,NULL,w,h,8,3,4);
+ if(!res->server)
+ return FALSE;
res->server->screenData=res;
res->server->port=res->listen_port;
res->server->frameBuffer=res->client->frameBuffer;
diff --git a/examples/backchannel.c b/examples/backchannel.c
index 7aa0fa1..c625753 100644
--- a/examples/backchannel.c
+++ b/examples/backchannel.c
@@ -107,6 +107,8 @@ int main(int argc,char** argv)
rfbRegisterProtocolExtension(&backChannelExtension);
server=rfbGetScreen(&argc,argv,400,300,8,3,4);
+ if(!server)
+ return 0;
server->frameBuffer=(char*)malloc(400*300*4);
rfbInitServer(server);
rfbRunEventLoop(server,-1,FALSE);
diff --git a/examples/camera.c b/examples/camera.c
index 7077790..58ab1c3 100644
--- a/examples/camera.c
+++ b/examples/camera.c
@@ -133,6 +133,8 @@ int main(int argc,char** argv)
long usec;
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,WIDTH,HEIGHT,8,3,BPP);
+ if(!server)
+ return 0;
server->desktopName = "Live Video Feed Example";
server->frameBuffer=(char*)malloc(WIDTH*HEIGHT*BPP);
server->alwaysShared=(1==1);
diff --git a/examples/colourmaptest.c b/examples/colourmaptest.c
index e403164..20ea303 100644
--- a/examples/colourmaptest.c
+++ b/examples/colourmaptest.c
@@ -7,7 +7,8 @@ int main(int argc,char** argv)
uint8_t bytes[256*3];
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,256,256,8,1,1);
-
+ if(!server)
+ return 0;
server->serverFormat.trueColour=FALSE;
server->colourMap.count=256;
server->colourMap.is16=FALSE;
diff --git a/examples/example.c b/examples/example.c
index 31bc38d..93fdf28 100644
--- a/examples/example.c
+++ b/examples/example.c
@@ -279,8 +279,9 @@ static void MakeRichCursor(rfbScreenInfoPtr rfbScreen)
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 = "LibVNCServer Example";
rfbScreen->frameBuffer = (char*)malloc(maxx*maxy*bpp);
rfbScreen->alwaysShared = TRUE;
diff --git a/examples/filetransfer.c b/examples/filetransfer.c
index ff4af11..2d03fe1 100644
--- a/examples/filetransfer.c
+++ b/examples/filetransfer.c
@@ -7,6 +7,8 @@
int main(int argc,char** argv)
{
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,8,3,4);
+ if(!server)
+ return 0;
server->frameBuffer=(char*)malloc(400*300*4);
rfbRegisterTightVNCFileTransferExtension();
rfbInitServer(server);
diff --git a/examples/fontsel.c b/examples/fontsel.c
index 85d2624..15139dc 100644
--- a/examples/fontsel.c
+++ b/examples/fontsel.c
@@ -41,6 +41,9 @@ int main(int argc,char** argv)
rfbScreenInfoPtr s=rfbGetScreen(&argc,argv,640,480,8,3,3);
int i,j;
+ if(!s)
+ return 0;
+
s->frameBuffer=(char*)malloc(640*480*3);
rfbInitServer(s);
diff --git a/examples/mac.c b/examples/mac.c
index 2d335a4..1c85d73 100644
--- a/examples/mac.c
+++ b/examples/mac.c
@@ -455,6 +455,8 @@ ScreenInit(int argc, char**argv)
CGDisplayPixelsHigh(kCGDirectMainDisplay),
bitsPerSample,
CGDisplaySamplesPerPixel(kCGDirectMainDisplay),4);
+ if(!rfbScreen)
+ exit(0);
rfbScreen->serverFormat.redShift = bitsPerSample*2;
rfbScreen->serverFormat.greenShift = bitsPerSample*1;
rfbScreen->serverFormat.blueShift = 0;
diff --git a/examples/pnmshow.c b/examples/pnmshow.c
index 734155f..6ced92a 100644
--- a/examples/pnmshow.c
+++ b/examples/pnmshow.c
@@ -65,6 +65,8 @@ int main(int argc,char** argv)
/* initialize data for vnc server */
rfbScreen = rfbGetScreen(&argc,argv,paddedWidth,height,8,(bitsPerPixelInFile+7)/8,bytesPerPixel);
+ if(!rfbScreen)
+ return 0;
if(argc>1)
rfbScreen->desktopName = argv[1];
else
diff --git a/examples/pnmshow24.c b/examples/pnmshow24.c
index a8d6c1d..81389d7 100644
--- a/examples/pnmshow24.c
+++ b/examples/pnmshow24.c
@@ -60,6 +60,8 @@ int main(int argc,char** argv)
/* initialize data for vnc server */
rfbScreen = rfbGetScreen(&argc,argv,paddedWidth,height,8,3,3);
+ if(!rfbScreen)
+ return 0;
if(argc>1)
rfbScreen->desktopName = argv[1];
else
diff --git a/examples/simple.c b/examples/simple.c
index f6e94dc..6167d72 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -3,6 +3,8 @@
int main(int argc,char** argv)
{
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,8,3,4);
+ if(!server)
+ return 0;
server->frameBuffer=(char*)malloc(400*300*4);
rfbInitServer(server);
rfbRunEventLoop(server,-1,FALSE);
diff --git a/examples/simple15.c b/examples/simple15.c
index faff4f7..a90988e 100644
--- a/examples/simple15.c
+++ b/examples/simple15.c
@@ -9,7 +9,8 @@ int main(int argc,char** argv)
uint16_t* f;
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,5,3,2);
-
+ if(!server)
+ return 0;
server->frameBuffer=(char*)malloc(400*300*2);
f=(uint16_t*)server->frameBuffer;
for(j=0;j<300;j++)
diff --git a/examples/vncev.c b/examples/vncev.c
index 9ebafc9..ba9441a 100644
--- a/examples/vncev.c
+++ b/examples/vncev.c
@@ -112,6 +112,8 @@ static enum rfbNewClientAction newclient(rfbClientPtr cl)
int main(int argc,char** argv)
{
rfbScreenInfoPtr s=rfbGetScreen(&argc,argv,width,height,8,1,1);
+ if(!s)
+ return 0;
s->colourMap.is16=FALSE;
s->colourMap.count=2;
s->colourMap.data.bytes=(unsigned char*)"\xd0\xd0\xd0\x30\x01\xe0";
diff --git a/examples/zippy.c b/examples/zippy.c
index d8a90d7..4f793a9 100644
--- a/examples/zippy.c
+++ b/examples/zippy.c
@@ -27,6 +27,8 @@ int main (int argc, char **argv)
return 1;
server = rfbGetScreen (&argc, argv, maxx, maxy, 8, 3, bpp);
+ if(!server)
+ return 0;
server->desktopName = "Zippy das wundersquirrel\'s VNC server";
server->frameBuffer = (char*)malloc(maxx*maxy*bpp);
server->alwaysShared = TRUE;
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;