Browse Source

Check rfbGetScreen() return value everywhere.

This fixes a segfault when a server is invoked with the
'-help' commandline argument.
pull/1/head
Christian Beier 12 years ago
parent
commit
bf2470cec6
  1. 2
      VisualNaCro/nacro.c
  2. 2
      examples/backchannel.c
  3. 2
      examples/camera.c
  4. 3
      examples/colourmaptest.c
  5. 5
      examples/example.c
  6. 2
      examples/filetransfer.c
  7. 3
      examples/fontsel.c
  8. 2
      examples/mac.c
  9. 2
      examples/pnmshow.c
  10. 2
      examples/pnmshow24.c
  11. 2
      examples/simple.c
  12. 3
      examples/simple15.c
  13. 2
      examples/vncev.c
  14. 2
      examples/zippy.c
  15. 3
      test/cargstest.c
  16. 2
      test/copyrecttest.c
  17. 6
      test/cursortest.c
  18. 2
      test/encodingstest.c

2
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;

2
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);

2
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);

3
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;

5
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;

2
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);

3
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);

2
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;

2
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

2
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

2
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);

3
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++)

2
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";

2
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;

3
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);

2
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;

6
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;

2
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;

Loading…
Cancel
Save