diff options
author | Christian Beier <dontmind@freeshell.org> | 2011-03-17 13:11:59 +0100 |
---|---|---|
committer | Christian Beier <dontmind@freeshell.org> | 2011-03-17 13:11:59 +0100 |
commit | bf2470cec69ab00f7213aa136f5a2d486c9da17a (patch) | |
tree | 9ff1c77459eabd1ef1fc594c190cbb455c92a0bd /examples | |
parent | 6b60690a4a1642c77bd6ac42789c4da6ed770075 (diff) | |
download | libtdevnc-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 'examples')
-rw-r--r-- | examples/backchannel.c | 2 | ||||
-rw-r--r-- | examples/camera.c | 2 | ||||
-rw-r--r-- | examples/colourmaptest.c | 3 | ||||
-rw-r--r-- | examples/example.c | 5 | ||||
-rw-r--r-- | examples/filetransfer.c | 2 | ||||
-rw-r--r-- | examples/fontsel.c | 3 | ||||
-rw-r--r-- | examples/mac.c | 2 | ||||
-rw-r--r-- | examples/pnmshow.c | 2 | ||||
-rw-r--r-- | examples/pnmshow24.c | 2 | ||||
-rw-r--r-- | examples/simple.c | 2 | ||||
-rw-r--r-- | examples/simple15.c | 3 | ||||
-rw-r--r-- | examples/vncev.c | 2 | ||||
-rw-r--r-- | examples/zippy.c | 2 |
13 files changed, 28 insertions, 4 deletions
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; |