int result; char *buffer; XpmImage image; ... /* 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): strcpy(s, "\",\n"); l = s + 3 - buf; if( *data_size >= UINT_MAX-l || *data_size + l <= *used_size || (*data_size + l - *used_size) <= sizeof(buf)) return(XpmNoMemory); 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: commit 50986a34f231fbc7a4b62466bd89bd4ae4027d2e Author: Matthieu Herrb <matthieu.herrb@laas.fr> 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.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.