in rfbScreenCleanup(), free(ptr->frameBuffer); while not check null pointer. This may cause crash.
Because in my Android server example, to improve performance, I directly set screen->frameBuffer as fbmmap!
So in cleanup(), I munmap(fbmmap), then this memory pointer is not valid anymore. And then crash occurs while followed invoking rfbScreenCleanup().
To avoid crash, after munmap(fbmmap), I have to allocate some bytes memory and assign it to screen->frameBuffer for free.
I think in rfbScreenCleanup(), or do not free frameBuffer and let it free by userself or check it's validity before call free.