aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2016-12-14 11:50:21 +0100
committerUlrich Sibiller <uli42@gmx.de>2017-03-10 19:44:22 +0100
commita83022a4a97b12904cf5d79f399336fff2d30e43 (patch)
tree2c98469316012bf9d1c324bcd3b4dc3677159270 /nx-X11/programs
parent4e545710f9c4d14ed8188e4f89b8d9c2da7975ef (diff)
downloadnx-libs-a83022a4a97b12904cf5d79f399336fff2d30e43.tar.gz
nx-libs-a83022a4a97b12904cf5d79f399336fff2d30e43.tar.bz2
nx-libs-a83022a4a97b12904cf5d79f399336fff2d30e43.zip
Rootless.c: improve malloc failure handling
Diffstat (limited to 'nx-X11/programs')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Rootless.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
index 64ad83bba..7862a5557 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
@@ -315,6 +315,13 @@ void nxagentRootlessRestack(unsigned long children[], unsigned int nchildren)
Mask mask;
toplevel = malloc(sizeof(WindowPtr) * nchildren);
+
+ if (!toplevel)
+ {
+ /* FIXME: Is this too much and we and simply return here? */
+ FatalError("nxagentRootlessRestack: malloc() failed.");
+ }
+
ntoplevel = 0;
for(i = 0; i < nchildren; i++)
@@ -497,6 +504,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
#ifdef _XSERVER64
else if (strcmp(typeS, "CARDINAL") == 0 || strcmp(typeS, "WM_SIZE_HINTS") == 0)
{
+ /* FIXME: is it okay here to ignore malloc fails? */
unsigned long *buffer = malloc(nUnits * sizeof(*buffer));
int *input = value;
int i;
@@ -640,6 +648,14 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
int i;
int j = 0;
+ if (!atoms)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '%s'- bailing out.\n", typeS);
+ #endif
+ return False;
+ }
+
freeMem = True;
export = True;
output = (char *) atoms;
@@ -690,6 +706,14 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
WindowPtr pWindow;
int i;
+ if (!wind)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '%s' - bailing out.\n", typeS);
+ #endif
+ return False;
+ }
+
freeMem = True;
export = True;
output = (char*) wind;
@@ -1037,7 +1061,7 @@ void nxagentImportProperty(Window window,
if (atoms == NULL)
{
#ifdef WARNING
- fprintf(stderr, "nxagentImportProperty: WARNING! Malloc failed bailing out.\n");
+ fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '%s' - bailing out.\n", typeS);
#endif
return;
@@ -1067,6 +1091,14 @@ void nxagentImportProperty(Window window,
WindowPtr pWindow;
int i;
+ if (!wind)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '%s' - bailing out.\n", typeS);
+ #endif
+
+ return;
+ }
freeMem = True;
import = True;
output = (char*) wind;
@@ -1185,7 +1217,7 @@ void nxagentAddPropertyToList(Atom property, WindowPtr pWin)
if ((tmp = malloc(sizeof(struct nxagentPropertyRec))) == NULL)
{
- FatalError("nxagentAddPropertyToList: malloc failed.");
+ FatalError("nxagentAddPropertyToList: malloc() failed.");
}
#ifdef TEST