On 11/30/15 12:54 PM, Miod Vallat wrote:
This is a potpourri of missing memory allocation checks. Routines will return
BadAlloc whenever possible, or fall back to a different behaviour, whenever
possible. Unfortunately some functions are void and can not propagate failure
to their callers.
Signed-off-by: Miod Vallat <[email protected]>
---
Xext/panoramiX.c | 15 ++++++++++++++-
Xext/panoramiXprocs.c | 16 ++++++++++++++++
Xext/xres.c | 2 ++
Xi/getprop.c | 3 +++
Xi/getselev.c | 2 ++
dix/enterleave.c | 2 ++
dix/window.c | 2 ++
exa/exa_accel.c | 12 ++++++++++++
glamor/glamor_core.c | 10 +++++++---
hw/dmx/config/dmxconfig.c | 18 ++++++++++++++++++
hw/dmx/dmxcursor.c | 6 ++++--
hw/dmx/dmxextension.c | 3 +++
hw/dmx/dmxfont.c | 8 ++++++++
hw/dmx/dmxgc.c | 24 +++++++++++++-----------
hw/dmx/dmxinit.c | 14 +++++++++-----
hw/dmx/dmxpict.c | 8 ++++++++
hw/dmx/dmxprop.c | 15 ++++++++++++---
hw/dmx/dmxwindow.c | 48 +++++++++++++++++++++++++----------------------
18 files changed, 161 insertions(+), 47 deletions(-)
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 209df29..7b94ba7 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -807,7 +807,7 @@ extern void
PanoramiXConsolidate(void)
{
int i;
- PanoramiXRes *root, *defmap, *saver;
+ PanoramiXRes *root = NULL, *defmap = NULL, *saver = NULL;
ScreenPtr pScreen = screenInfo.screens[0];
DepthPtr pDepth = pScreen->allowedDepths;
VisualPtr pVisual = pScreen->visuals;
@@ -822,10 +822,16 @@ PanoramiXConsolidate(void)
PanoramiXMaybeAddVisual(pVisual++);
root = malloc(sizeof(PanoramiXRes));
+ if (!root)
+ goto outOfMemory;
root->type = XRT_WINDOW;
defmap = malloc(sizeof(PanoramiXRes));
+ if (!defmap)
+ goto outOfMemory;
defmap->type = XRT_COLORMAP;
saver = malloc(sizeof(PanoramiXRes));
+ if (!saver)
+ goto outOfMemory;
saver->type = XRT_WINDOW;
FOR_NSCREENS(i) {
@@ -843,6 +849,13 @@ PanoramiXConsolidate(void)
AddResource(root->info[0].id, XRT_WINDOW, root);
AddResource(saver->info[0].id, XRT_WINDOW, saver);
AddResource(defmap->info[0].id, XRT_COLORMAP, defmap);
+
+ return;
+
+ outOfMemory:
+ free(saver);
+ free(defmap);
+ free(root);
}
VisualID
I'd be tempted to just change those to XNFalloc() instead, since if we can't
allocate memory for a struct that small in the Xserver initialization process,
we're going to crash and burn soon anyway.
The rest look good to me, thanks.
--
-Alan Coopersmith- [email protected]
Oracle Solaris Engineering - http://blogs.oracle.com/alanc
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel