Commit eaecbf4b authored by runge's avatar runge

Handle colormaps with more than 256 colors.

parent f164dc18
......@@ -3062,12 +3062,20 @@ rfbSendSetColourMapEntries(rfbClientPtr cl,
int nColours)
{
char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2];
rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf;
uint16_t *rgb = (uint16_t *)(&buf[sz_rfbSetColourMapEntriesMsg]);
char *wbuf = buf;
rfbSetColourMapEntriesMsg *scme;
uint16_t *rgb;
rfbColourMap* cm = &cl->screen->colourMap;
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->firstColour = Swap16IfLE(firstColour);
......@@ -3091,13 +3099,15 @@ rfbSendSetColourMapEntries(rfbClientPtr cl,
len += nColours * 3 * 2;
if (rfbWriteExact(cl, buf, len) < 0) {
if (rfbWriteExact(cl, wbuf, len) < 0) {
rfbLogPerror("rfbSendSetColourMapEntries: write");
rfbCloseClient(cl);
if (wbuf != buf) free(wbuf);
return FALSE;
}
rfbStatRecordMessageSent(cl, rfbSetColourMapEntries, len, len);
if (wbuf != buf) free(wbuf);
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