/* xpm image creation */
result = XpmCreateBufferFromXpmImage(&buffer, &image, NULL);
result is always -3 (XpmNoMemory)
XpmWriteFileFromXpmImage() with the same arguments works fine.
I could track down the problem to this code segment of WriteColors() in src/CrBufFrI.c (near line 314):
l = s + 3 - buf;
if( *data_size >= UINT_MAX-l ||
*data_size + l <= *used_size ||
(*data_size + l - *used_size) <= sizeof(buf))
The last comparison is always true (under normal circumstances) and therefore this function returns XpmNoMemory. Is this check really necessary?
The call of XpmCreateBufferFromXpmImage() worked as expected after removing the third comparison.
This check was added in:
Author: Matthieu Herrb <email@example.com>
Date: Thu Nov 25 21:19:11 2004 +0000
Fixes for CAN-2004-0914 (Thomas Biege).
It really doesn't make sense to me. Not looking at the context and just
looking at the check, it makes no sense to do *both* of these checks:
+ *data_size + l <= *used_size ||
+ (*data_size + l - *used_size) <= sizeof(buf))
Looking a bit more at the context, I think that check is entirely bogus. I've
sent a patch to xorg-devel for review which removes it.
Mass closure: This bug has been untouched for more than six years, and is not
obviously still valid. Please reopen this bug or file a new report if you continue to experience issues with current releases.