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>
This commit is contained in:
parent
8f69c935f6
commit
0f380a5005
|
@ -991,7 +991,6 @@ CreatePmap:
|
||||||
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
||||||
pMap->drawable.id = newPix->info[j].id;
|
pMap->drawable.id = newPix->info[j].id;
|
||||||
if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) {
|
if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) {
|
||||||
(*pScreen->DestroyPixmap)(pMap);
|
|
||||||
result = BadAlloc;
|
result = BadAlloc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1002,10 +1001,8 @@ CreatePmap:
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result == BadAlloc) {
|
if(result == BadAlloc) {
|
||||||
while(j--) {
|
while(j--)
|
||||||
(*pScreen->DestroyPixmap)(pMap);
|
|
||||||
FreeResource(newPix->info[j].id, RT_NONE);
|
FreeResource(newPix->info[j].id, RT_NONE);
|
||||||
}
|
|
||||||
free(newPix);
|
free(newPix);
|
||||||
} else
|
} else
|
||||||
AddResource(stuff->pid, XRT_PIXMAP, newPix);
|
AddResource(stuff->pid, XRT_PIXMAP, newPix);
|
||||||
|
@ -1110,7 +1107,6 @@ CreatePmap:
|
||||||
{
|
{
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
pDraw->pScreen->DestroyPixmap(pMap);
|
|
||||||
}
|
}
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1419,7 +1419,6 @@ CreatePmap:
|
||||||
}
|
}
|
||||||
if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
|
if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
|
||||||
return Success;
|
return Success;
|
||||||
(*pDraw->pScreen->DestroyPixmap)(pMap);
|
|
||||||
}
|
}
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue