mirror of
https://github.com/sheumann/VNCviewGS.git
synced 2024-11-25 06:31:36 +00:00
Improved error handling in local cursor code
This commit is contained in:
parent
60c976dda6
commit
8c18d44109
28
mouse.cc
28
mouse.cc
@ -153,25 +153,26 @@ void DoCursor (void) {
|
|||||||
unsigned int outBytes640;
|
unsigned int outBytes640;
|
||||||
unsigned long outBytes320;
|
unsigned long outBytes320;
|
||||||
|
|
||||||
bitmaskLineBytes = (rectWidth + 7) / 8;
|
bitmaskLineBytes = ((unsigned long)rectWidth + 7) / 8;
|
||||||
|
|
||||||
if (!DoReadTCP(rectWidth*rectHeight + bitmaskLineBytes*rectHeight))
|
if (!DoReadTCP((unsigned long)rectWidth * rectHeight + bitmaskLineBytes * rectHeight))
|
||||||
return; /* Try again later */
|
return; /* Try again later */
|
||||||
|
|
||||||
HLock(readBufferHndl);
|
HLock(readBufferHndl);
|
||||||
|
|
||||||
cursorPixels = (unsigned char *)(*readBufferHndl);
|
cursorPixels = (unsigned char *)(*readBufferHndl);
|
||||||
bitmask = (unsigned char *)(*readBufferHndl) + rectWidth*rectHeight;
|
bitmask = (unsigned char *)(*readBufferHndl) + (unsigned long)rectWidth * rectHeight;
|
||||||
|
|
||||||
if (hRez == 640)
|
if (hRez == 640)
|
||||||
lineWords = (rectWidth + 7) / 8 + 1;
|
lineWords = ((unsigned long)rectWidth + 7) / 8 + 1;
|
||||||
else /* hRez == 320 */
|
else /* hRez == 320 */
|
||||||
lineWords = (rectWidth + 3) / 4 + 1;
|
lineWords = ((unsigned long)rectWidth + 3) / 4 + 1;
|
||||||
|
|
||||||
/* Don't overflow loop indices, and don't use ridiculously large cursors.
|
/* Don't overflow loop indices, and don't use really large cursors.
|
||||||
* (Is there a limit to the cursor sizes QuickDraw II can handle?) */
|
* (Is there a limit to the cursor sizes QuickDraw II can handle?) */
|
||||||
if ((lineWords > 16) || (rectHeight > 128)) {
|
if (lineWords > 16 || rectHeight > 128 || rectWidth == 0 || rectHeight == 0) {
|
||||||
InitCursor();
|
InitCursor();
|
||||||
|
cursor = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,12 +286,8 @@ void DoCursor (void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HUnlock(readBufferHndl);
|
|
||||||
|
|
||||||
if (GetCursorAdr() == oldCursor)
|
if (GetCursorAdr() == oldCursor)
|
||||||
SetCursor(cursor);
|
SetCursor(cursor);
|
||||||
if (oldCursor)
|
|
||||||
free(oldCursor);
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/***************/
|
/***************/
|
||||||
@ -310,11 +307,6 @@ void DoCursor (void) {
|
|||||||
}
|
}
|
||||||
for (k = cursorImage + j; k < cursorImage + j + 4; k = k + 1)
|
for (k = cursorImage + j; k < cursorImage + j + 4; k = k + 1)
|
||||||
fprintf(foo, "%02X ", *k);
|
fprintf(foo, "%02X ", *k);
|
||||||
//for (j = 0; j < bitmaskLineBytes*rectHeight; j++) {
|
|
||||||
// fprintf(foo, "%02X", *(bitmask + j));
|
|
||||||
// if ((j+1) % bitmaskLineBytes == 0)
|
|
||||||
// fprintf(foo, "\n");
|
|
||||||
//}
|
|
||||||
fprintf(foo, "\n");
|
fprintf(foo, "\n");
|
||||||
fclose(foo);
|
fclose(foo);
|
||||||
}
|
}
|
||||||
@ -322,6 +314,8 @@ void DoCursor (void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
HUnlock(readBufferHndl);
|
||||||
|
free(oldCursor);
|
||||||
displayInProgress = FALSE;
|
displayInProgress = FALSE;
|
||||||
NextRect(); /* Prepare for next rect */
|
NextRect(); /* Prepare for next rect */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user