KPixmapIO bug in ShmSegment

Karl Vogel kvo--kde at seagha.be
Mon Feb 10 22:14:00 GMT 2003


Lubos Lunak wrote:

> On Saturday 08 of February 2003 14:53, Karl Vogel wrote:
> [snip]
>> void KPixmapIO::initXImage(int w, int h)
>>  {
>>  if (d->ximage && (w == d->ximage->width) && (h == d->ximage->height))
>>  return;
>>
>>  createXImage(w, h);
>>  int size = d->ximage->bytes_per_line * d->ximage->height;
>>  if (size > d->shmsize)
>>  createShmSegment(size);
>>  d->ximage->data = d->shminfo->shmaddr;
>>  return;
>>  }
>>
>> If createShmSegment() is unable attach the shm segment, then it sets
>> m_bShm to false. In this case d->shminfo->shmaddr is not valid! So there
>> needs to be a test written for this case.
>>
>>
>>
>> Bumped onto this via:
>>  http://bugs.kde.org/show_bug.cgi?id=42441
> 
>  Do the attached patches help?
> 

Your patch works. But I discovered another little bug in the shmat() call
that was causing a problem.

shmat() returns -1 for failure, however testing the return against < 0,
after converting it to char*, always returns false on my system (gcc
version 3.2 20020903 (Red Hat Linux 8.0 3.2-7))

Therefor it's better to compare with ==(char *)-1

(patch against your version is attached)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kpixmapio.cpp.patch2
Type: text/x-diff
Size: 418 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20030210/817896bf/attachment.diff>


More information about the kde-core-devel mailing list