Commit eaecbf4b authored by runge's avatar runge

Handle colormaps with more than 256 colors.

parent f164dc18
...@@ -3062,12 +3062,20 @@ rfbSendSetColourMapEntries(rfbClientPtr cl, ...@@ -3062,12 +3062,20 @@ rfbSendSetColourMapEntries(rfbClientPtr cl,
int nColours) int nColours)
{ {
char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2]; char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2];
rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf; char *wbuf = buf;
uint16_t *rgb = (uint16_t *)(&buf[sz_rfbSetColourMapEntriesMsg]); rfbSetColourMapEntriesMsg *scme;
uint16_t *rgb;
rfbColourMap* cm = &cl->screen->colourMap; rfbColourMap* cm = &cl->screen->colourMap;
int i, len; int i, len;
if (nColours > 256) {
/* some rare hardware has, e.g., 4096 colors cells: PseudoColor:12 */
wbuf = (char *) malloc(sz_rfbSetColourMapEntriesMsg + nColours * 3 * 2);
}
scme = (rfbSetColourMapEntriesMsg *)wbuf;
rgb = (uint16_t *)(&wbuf[sz_rfbSetColourMapEntriesMsg]);
scme->type = rfbSetColourMapEntries; scme->type = rfbSetColourMapEntries;
scme->firstColour = Swap16IfLE(firstColour); scme->firstColour = Swap16IfLE(firstColour);
...@@ -3091,13 +3099,15 @@ rfbSendSetColourMapEntries(rfbClientPtr cl, ...@@ -3091,13 +3099,15 @@ rfbSendSetColourMapEntries(rfbClientPtr cl,
len += nColours * 3 * 2; len += nColours * 3 * 2;
if (rfbWriteExact(cl, buf, len) < 0) { if (rfbWriteExact(cl, wbuf, len) < 0) {
rfbLogPerror("rfbSendSetColourMapEntries: write"); rfbLogPerror("rfbSendSetColourMapEntries: write");
rfbCloseClient(cl); rfbCloseClient(cl);
if (wbuf != buf) free(wbuf);
return FALSE; return FALSE;
} }
rfbStatRecordMessageSent(cl, rfbSetColourMapEntries, len, len); rfbStatRecordMessageSent(cl, rfbSetColourMapEntries, len, len);
if (wbuf != buf) free(wbuf);
return TRUE; return TRUE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment