mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-29 10:20:08 +01:00
Fix pixmap double-frees on error paths.
If AddResource fails, it will automatically free the object that was
passed to it by calling the appropriate deleteFunc; and of course
FreeResource also calls the deleteFunc. In both cases it's wrong to call
the destroy hook manually.
Commit by Jamey Sharp and Josh Triplett.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
(cherry picked from commit 0f380a5005)
This commit is contained in:
parent
aabd25bd0b
commit
bd6ea85209
2 changed files with 1 additions and 6 deletions
|
|
@ -991,7 +991,6 @@ CreatePmap:
|
|||
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
||||
pMap->drawable.id = newPix->info[j].id;
|
||||
if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) {
|
||||
(*pScreen->DestroyPixmap)(pMap);
|
||||
result = BadAlloc;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1002,10 +1001,8 @@ CreatePmap:
|
|||
}
|
||||
|
||||
if(result == BadAlloc) {
|
||||
while(j--) {
|
||||
(*pScreen->DestroyPixmap)(pMap);
|
||||
while(j--)
|
||||
FreeResource(newPix->info[j].id, RT_NONE);
|
||||
}
|
||||
free(newPix);
|
||||
} else
|
||||
AddResource(stuff->pid, XRT_PIXMAP, newPix);
|
||||
|
|
@ -1110,7 +1107,6 @@ CreatePmap:
|
|||
{
|
||||
return Success;
|
||||
}
|
||||
pDraw->pScreen->DestroyPixmap(pMap);
|
||||
}
|
||||
return BadAlloc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1419,7 +1419,6 @@ CreatePmap:
|
|||
}
|
||||
if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
|
||||
return Success;
|
||||
(*pDraw->pScreen->DestroyPixmap)(pMap);
|
||||
}
|
||||
return BadAlloc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue