aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Args.c14
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Atoms.c16
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Clipboard.c3
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Colormap.c21
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Cursor.c7
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Display.c65
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Drawable.c11
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Error.c13
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Events.c35
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Font.c63
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/GC.c18
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/GCOps.c7
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Image.c27
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keyboard.c70
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keystroke.c4
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Pixmap.c13
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Reconnect.c12
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Render.c5
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Rootless.c15
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Screen.c73
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Utils.h1
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Window.c40
22 files changed, 217 insertions, 316 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c
index 161403cd0..1d8beca3d 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Args.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c
@@ -195,7 +195,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
char *basec = strdup(argv[0]);
nxagentProgName = strdup(basename(basec));
- free(basec);
+ SAFE_free(basec);
/*
* Check if we are running as X2Go Agent
@@ -270,7 +270,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
nxagentParseOptionString(envOptions);
- free(envOptions);
+ SAFE_free(envOptions);
}
for (j = 0; j < argc; j++)
@@ -378,8 +378,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
if (++i < argc)
{
- free(nxagentOptionsFilenameOrString);
- nxagentOptionsFilenameOrString = NULL;
+ SAFE_free(nxagentOptionsFilenameOrString);
if (-1 == asprintf(&nxagentOptionsFilenameOrString, "%s", argv[i]))
{
@@ -716,8 +715,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
if (++i < argc)
{
- free(nxagentKeyboard);
- nxagentKeyboard = NULL;
+ SAFE_free(nxagentKeyboard);
nxagentKeyboard = strdup(argv[i]);
if (nxagentKeyboard == NULL)
@@ -1574,7 +1572,7 @@ static void nxagentParseSingleOption(char *name, char *value)
ddxProcessArgument(argc, argv, 0);
- free(argv[0]);
+ SAFE_free(argv[0]);
}
static void nxagentParseOptionString(char *string)
@@ -1761,7 +1759,7 @@ void nxagentProcessOptionsFile(char * filename)
nxagentProcessOptionsFileExit:
- free(data);
+ SAFE_free(data);
if (file)
{
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
index c36c38e2f..2ee67b9bb 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
@@ -43,6 +43,7 @@
#include "Screen.h"
#include "Options.h"
#include "Agent.h"
+#include "Utils.h"
/*
* Set here the required log level.
@@ -53,11 +54,6 @@
#undef TEST
#undef DEBUG
-#ifdef DEBUG
-/* for validateString() */
-#include "Utils.h"
-#endif
-
/*
* These values should be moved in
* the option repository.
@@ -482,8 +478,8 @@ static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet)
fprintf(stderr, "nxagentInitAtomMap: WARNING! XInternAtoms request failed.\n");
#endif
- free(atom_list);
- free(name_list);
+ SAFE_free(atom_list);
+ SAFE_free(name_list);
return 0;
}
@@ -523,8 +519,8 @@ static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet)
}
}
- free(atom_list);
- free(name_list);
+ SAFE_free(atom_list);
+ SAFE_free(name_list);
nxagentPrintAtomMapInfo("nxagentInitAtomMap: Exiting");
@@ -794,7 +790,7 @@ Atom nxagentRemoteToLocalAtom(Atom remote)
#ifdef TEST
fprintf(stderr, "%s: remote [%d (%s)] -> local [%d]\n", __func__, remote, string, local);
#endif
- XFree(string);
+ SAFE_XFree(string);
return local;
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
index 9c518801b..024d685ba 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
@@ -1783,8 +1783,7 @@ int nxagentInitClipboard(WindowPtr pWin)
fprintf(stderr, "%s: Got called.\n", __func__);
#endif
- free(lastSelectionOwner);
- lastSelectionOwner = NULL;
+ SAFE_free(lastSelectionOwner);
lastSelectionOwner = (SelectionOwner *) malloc(nxagentMaxSelections * sizeof(SelectionOwner));
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c
index 401f05b94..33b0738ec 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c
@@ -54,6 +54,7 @@ is" without express or implied warranty.
#include "Visual.h"
#include "Windows.h"
#include "Args.h"
+#include "Utils.h"
#define PANIC
#define WARNING
@@ -120,7 +121,7 @@ Bool nxagentCreateColormap(ColormapPtr pCmap)
pCmap->red[i].co.local.green = colors[i].red;
pCmap->red[i].co.local.blue = colors[i].red;
}
- free(colors);
+ SAFE_free(colors);
break;
case StaticColor: /* read only */
@@ -133,7 +134,7 @@ Bool nxagentCreateColormap(ColormapPtr pCmap)
pCmap->red[i].co.local.green = colors[i].green;
pCmap->red[i].co.local.blue = colors[i].blue;
}
- free(colors);
+ SAFE_free(colors);
break;
case TrueColor: /* read only */
@@ -157,7 +158,7 @@ Bool nxagentCreateColormap(ColormapPtr pCmap)
pCmap->green[i].co.local.green = colors[i].green;
pCmap->blue[i].co.local.blue = colors[i].blue;
}
- free(colors);
+ SAFE_free(colors);
break;
case GrayScale: /* read and write */
@@ -176,7 +177,7 @@ Bool nxagentCreateColormap(ColormapPtr pCmap)
void nxagentDestroyColormap(ColormapPtr pCmap)
{
XFreeColormap(nxagentDisplay, nxagentColormap(pCmap));
- free(pCmap->devPriv);
+ SAFE_free(pCmap->devPriv);
}
#define SEARCH_PREDICATE \
@@ -254,10 +255,10 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
numWindows = 0;
}
- free(icws.cmapIDs);
+ SAFE_free(icws.cmapIDs);
if (!nxagentSameInstalledColormapWindows(icws.windows, icws.numWindows)) {
- free(nxagentOldInstalledColormapWindows);
+ SAFE_free(nxagentOldInstalledColormapWindows);
#ifdef _XSERVER64
{
@@ -268,7 +269,7 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
windows[i] = icws.windows[i];
XSetWMColormapWindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum],
windows, numWindows);
- free(windows);
+ SAFE_free(windows);
}
#else
XSetWMColormapWindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum],
@@ -317,12 +318,12 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
#endif /* DUMB_WINDOW_MANAGERS */
}
else
- free(icws.windows);
+ SAFE_free(icws.windows);
}
void nxagentSetScreenSaverColormapWindow(ScreenPtr pScreen)
{
- free(nxagentOldInstalledColormapWindows);
+ SAFE_free(nxagentOldInstalledColormapWindows);
#ifdef _XSERVER64
{
@@ -454,7 +455,7 @@ void nxagentStoreColors(ColormapPtr pCmap, int nColors, xColorItem *pColors)
pColors64[i].flags = pColors[i].flags;
}
XStoreColors(nxagentDisplay, nxagentColormap(pCmap), pColors64, nColors);
- free(pColors64);
+ SAFE_free(pColors64);
}
#else
XStoreColors(nxagentDisplay, nxagentColormap(pCmap),
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c
index a67115cec..75382d4e8 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c
@@ -61,6 +61,7 @@ is" without express or implied warranty.
#include "Events.h"
#include "Render.h"
#include "Client.h"
+#include "Utils.h"
#include "windowstr.h"
#include "resource.h"
@@ -211,7 +212,7 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
XPutImage(nxagentDisplay, source, nxagentBitmapGC, image,
0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height);
- XFree(image);
+ SAFE_XFree(image);
image = XCreateImage(nxagentDisplay,
nxagentDefaultVisual(pScreen),
@@ -229,7 +230,7 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
XPutImage(nxagentDisplay, mask, nxagentBitmapGC, image,
0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height);
- XFree(image);
+ SAFE_XFree(image);
fg_color.red = pCursor->foreRed;
fg_color.green = pCursor->foreGreen;
@@ -264,14 +265,12 @@ Bool nxagentUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
if (nxagentCursorUsesRender(pCursor, pScreen))
{
PicturePtr pPicture = nxagentCursorPicture(pCursor, pScreen);
-
FreePicture(pPicture, pPicture -> id);
}
if (nxagentCursor(pCursor, pScreen) != None)
{
XFreeCursor(nxagentDisplay, nxagentCursor(pCursor, pScreen));
-
nxagentCursor(pCursor, pScreen) = None;
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c
index 4bce82783..c25afc597 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Display.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c
@@ -71,6 +71,7 @@ is" without express or implied warranty.
#include "Init.h"
#include "Args.h"
#include "Image.h"
+#include "Utils.h"
#define Pixmap XlibPixmap
#include "Icons.h"
@@ -1534,7 +1535,7 @@ void nxagentInitVisuals(void)
nxagentNumVisuals * sizeof(XVisualInfo));
}
- XFree(viList);
+ SAFE_XFree(viList);
if (nxagentNumVisuals == 0 || nxagentVisuals == NULL)
{
@@ -1756,20 +1757,11 @@ void nxagentCloseDisplay(void)
* traffic
*/
- free(nxagentDefaultColormaps);
- nxagentDefaultColormaps = NULL;
-
- XFree(nxagentVisuals);
- nxagentVisuals = NULL;
-
- free(nxagentDepths);
- nxagentDepths = NULL;
-
- XFree(nxagentPixmapFormats);
- nxagentPixmapFormats = NULL;
-
- XFree(nxagentRemotePixmapFormats);
- nxagentRemotePixmapFormats = NULL;
+ SAFE_free(nxagentDefaultColormaps);
+ SAFE_free(nxagentDepths);
+ SAFE_XFree(nxagentVisuals);
+ SAFE_XFree(nxagentPixmapFormats);
+ SAFE_XFree(nxagentRemotePixmapFormats);
nxagentFreeFontCache();
/*
@@ -2008,11 +2000,7 @@ void nxagentBackupDisplayInfo(void)
nxagentNumDefaultColormapsRecBackup = nxagentNumDefaultColormaps;
nxagentVisualsRecBackup = nxagentVisuals;
nxagentNumVisualsRecBackup = nxagentNumVisuals;
- if (nxagentVisualHasBeenIgnored)
- {
- free(nxagentVisualHasBeenIgnored);
- nxagentVisualHasBeenIgnored = NULL;
- }
+ SAFE_free(nxagentVisualHasBeenIgnored);
nxagentVisualHasBeenIgnored = malloc(nxagentNumVisuals * sizeof(Bool));
nxagentDefaultDepthRecBackup = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay));
nxagentDisplayWidthRecBackup = DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay));
@@ -2024,20 +2012,11 @@ void nxagentBackupDisplayInfo(void)
void nxagentCleanupBackupDisplayInfo(void)
{
- free(nxagentDepthsRecBackup);
- nxagentNumDepthsRecBackup = 0;
+ SAFE_free(nxagentDepthsRecBackup);
+ SAFE_free(nxagentVisualsRecBackup);
+ SAFE_free(nxagentVisualHasBeenIgnored);
nxagentNumDefaultColormapsRecBackup = 0;
-
- free(nxagentVisualsRecBackup);
- nxagentNumVisualsRecBackup = 0;
-
- if (nxagentVisualHasBeenIgnored)
- {
- free(nxagentVisualHasBeenIgnored);
- nxagentVisualHasBeenIgnored = NULL;
- }
-
nxagentDefaultDepthRecBackup = 0;
nxagentDisplayWidthRecBackup = 0;
nxagentDisplayHeightRecBackup = 0;
@@ -2045,7 +2024,6 @@ void nxagentCleanupBackupDisplayInfo(void)
if (nxagentDisplayBackup)
{
XCloseDisplay(nxagentDisplayBackup);
-
nxagentDisplayBackup = NULL;
}
@@ -2057,7 +2035,7 @@ void nxagentCleanupBackupDisplayInfo(void)
}
else
{
- free(nxagentBitmapGCBackup);
+ SAFE_free(nxagentBitmapGCBackup);
}
nxagentBitmapGCBackup = NULL;
@@ -2560,7 +2538,7 @@ FIXME: Should the visual be ignored in this case?
}
}
- XFree(viList);
+ SAFE_XFree(viList);
if (compatible)
{
@@ -2576,7 +2554,7 @@ FIXME: Should the visual be ignored in this case?
fprintf(stderr, "nxagentInitAndCheckVisuals: New visuals don't match with old visuals.\n");
#endif
- free(newVisuals);
+ SAFE_free(newVisuals);
}
return compatible;
@@ -2757,19 +2735,8 @@ Bool nxagentReconnectDisplay(void *p0)
* will be reallocated in nxagentInitPixmapFormats().
*/
- if (nxagentPixmapFormats != NULL)
- {
- XFree(nxagentPixmapFormats);
-
- nxagentPixmapFormats = NULL;
- }
-
- if (nxagentRemotePixmapFormats != NULL)
- {
- XFree(nxagentRemotePixmapFormats);
-
- nxagentRemotePixmapFormats = NULL;
- }
+ SAFE_XFree(nxagentPixmapFormats);
+ SAFE_XFree(nxagentRemotePixmapFormats);
/*
* Check if all the required pixmap
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c
index 88f3da3a9..7574ec7b0 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c
@@ -42,6 +42,7 @@
#include "Pixels.h"
#include "Reconnect.h"
#include "GCOps.h"
+#include "Utils.h"
#include "compext/Compext.h"
@@ -365,7 +366,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = nxagentSynchronizeRegion(pDrawable, NullRegion, breakMask, owner);
nxagentSynchronizeDrawableDataEnd:
- free(data);
+ SAFE_free(data);
return success;
}
@@ -861,7 +862,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
#endif
}
- free(cmpData);
+ SAFE_free(cmpData);
}
}
else
@@ -1058,7 +1059,7 @@ nxagentSynchronizeRegionFree:
nxagentFreeRegion(pDrawable, clipRegion);
}
- free(data);
+ SAFE_free(data);
RegionUninit(&exposeRegion);
@@ -2158,7 +2159,7 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
fprintf(stderr, "nxagentGetColor: WARNING! Failed to create the XImage.\n");
#endif
- free(data);
+ SAFE_free(data);
return -1;
}
@@ -2384,7 +2385,7 @@ void nxagentFillRemoteRegion(DrawablePtr pDrawable, RegionPtr pRegion)
XFillRectangles(nxagentDisplay, nxagentDrawable(pDrawable), nxagentGC(pGC),
pRects, nrects);
- free(pRects);
+ SAFE_free(pRects);
}
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c
index bc58ef849..0d4ef3107 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Error.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c
@@ -42,6 +42,7 @@
#include "Error.h"
#include "Args.h"
+#include "Utils.h"
/*
* Set here the required log level.
@@ -425,7 +426,7 @@ char *nxagentGetRootPath(void)
"home directory '%s'.\n", homeEnv);
#endif
- free(homeEnv);
+ SAFE_free(homeEnv);
return NULL;
}
@@ -436,7 +437,7 @@ char *nxagentGetRootPath(void)
snprintf(nxagentRootDir, DEFAULT_STRING_LENGTH, "%s/.nx", homeEnv);
- free(homeEnv);
+ SAFE_free(homeEnv);
/*
* Create the NX root directory.
@@ -534,14 +535,14 @@ char *nxagentGetSessionPath(void)
nxagentSessionDir);
#endif
- free(rootPath);
+ SAFE_free(rootPath);
return NULL;
}
snprintf(nxagentSessionDir, DEFAULT_STRING_LENGTH, "%s/C-%s", rootPath, nxagentSessionId);
- free(rootPath);
+ SAFE_free(rootPath);
if ((stat(nxagentSessionDir, &dirStat) == -1) && (errno == ENOENT))
{
@@ -595,14 +596,14 @@ void nxagentGetClientsPath(void)
fprintf(stderr, "nxagentGetClientsPath: PANIC! Invalid value for the NX clients Log File Path ''.\n");
#endif
- free(sessionPath);
+ SAFE_free(sessionPath);
return;
}
snprintf(nxagentClientsLogName, NXAGENTCLIENTSLOGNAMELENGTH, "%s/clients", sessionPath);
- free(sessionPath);
+ SAFE_free(sessionPath);
}
return;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c
index fda84cf9b..553eaccd6 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c
@@ -328,7 +328,7 @@ void nxagentRemoteWindowID(Window window, Bool newline)
else if (winName)
{
fprintf(stderr, " \"%s\" ", winName);
- XFree(winName);
+ SAFE_XFree(winName);
}
#else
@@ -476,10 +476,7 @@ void nxagentRemoteWindowsTree(Window window, int level)
nxagentRemoteWindowsTree(childList[i], level + 1);
}
- if (childList)
- {
- XFree((char *) childList);
- }
+ SAFE_XFree((char *) childList);
}
#endif
@@ -3133,10 +3130,7 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X)
#endif
}
- if (children_return)
- {
- XFree(children_return);
- }
+ SAFE_XFree(children_return);
#if 0
fprintf(stderr, "nxagentCheckWindowConfiguration: Trees match: %s\n",
@@ -3514,11 +3508,7 @@ int nxagentHandleReparentNotify(XEvent* X)
result = XQueryTree(nxagentDisplay, w, &root_return,
&parent_return, &children_return, &nchildren_return);
- if (children_return)
- {
- XFree(children_return);
- children_return = NULL;
- }
+ SAFE_XFree(children_return);
if (!result)
{
@@ -3556,11 +3546,7 @@ int nxagentHandleReparentNotify(XEvent* X)
#endif
}
- if (children_return)
- {
- XFree(children_return);
- children_return = NULL;
- }
+ SAFE_XFree(children_return);
}
else
{
@@ -3624,11 +3610,7 @@ int nxagentHandleReparentNotify(XEvent* X)
result = XQueryTree(nxagentDisplay, w, &rootReturn, &parentReturn,
&childrenReturn, &nchildrenReturn);
- if (childrenReturn)
- {
- XFree(childrenReturn);
- childrenReturn = NULL;
- }
+ SAFE_XFree(childrenReturn);
if (parentReturn == rootReturn || parentReturn == 0 || result == 0)
{
@@ -4025,10 +4007,7 @@ void nxagentHandleCollectPropertyEvent(XEvent *X)
#endif
}
- if (pszReturnData != NULL)
- {
- XFree(pszReturnData);
- }
+ SAFE_XFree(pszReturnData);
return;
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c
index fb441d431..7370bc56d 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Font.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c
@@ -188,11 +188,11 @@ void nxagentFreeFontCache(void)
nxagentFreeFont(CACHE_FSTRUCT(i));
}
- free(CACHE_NAME(i));
- free(CACHE_ENTRY(i));
+ SAFE_free(CACHE_NAME(i));
+ SAFE_free(CACHE_ENTRY(i));
}
- free(CACHE_ENTRY_PTR);
+ SAFE_free(CACHE_ENTRY_PTR);
CACHE_ENTRY_PTR = NULL;
CACHE_INDEX = 0;
CACHE_SIZE = 0;
@@ -324,8 +324,7 @@ void nxagentListRemoteAddName(const char *name, int status)
if (nxagentRemoteFontList.list[pos]->name == NULL)
{
fprintf(stderr, "Font: remote list name memory allocation failed!.\n");
- free(nxagentRemoteFontList.list[pos]);
- nxagentRemoteFontList.list[pos] = NULL;
+ SAFE_free(nxagentRemoteFontList.list[pos]);
return;
}
}
@@ -351,18 +350,14 @@ static void nxagentFreeRemoteFontList(nxagentFontList *listRec)
{
if (listRec -> list[l])
{
- free(listRec -> list[l] -> name);
- listRec -> list[l] -> name = NULL;
-
- free(listRec -> list[l]);
- listRec -> list[l] = NULL;
+ SAFE_free(listRec -> list[l] -> name);
+ SAFE_free(listRec -> list[l]);
}
}
listRec -> length = listRec -> listSize = 0;
- free(listRec -> list);
- listRec -> list = NULL;
+ SAFE_free(listRec -> list);
return;
}
@@ -434,7 +429,7 @@ Bool nxagentFontLookUp(const char *name)
{
result = nxagentFontFind(scalable, &i);
- free(scalable);
+ SAFE_free(scalable);
}
}
@@ -448,7 +443,7 @@ Bool nxagentFontLookUp(const char *name)
{
result = nxagentFontFind(scalable, &i);
- free(scalable);
+ SAFE_free(scalable);
}
}
@@ -813,7 +808,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
for (j = 0; j < numSearchFields; j++)
{
- free(searchFields[j]);
+ SAFE_free(searchFields[j]);
}
}
}
@@ -830,7 +825,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
for (j = 0; j < numFontFields; j++)
{
- free(fontNameFields[j]);
+ SAFE_free(fontNameFields[j]);
}
return fontStruct;
@@ -890,10 +885,8 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id)
if (nxagentFailedToReconnectFonts.font == NULL || nxagentFailedToReconnectFonts.id == NULL)
{
- free(nxagentFailedToReconnectFonts.font);
- nxagentFailedToReconnectFonts.font = NULL;
- free(nxagentFailedToReconnectFonts.id);
- nxagentFailedToReconnectFonts.id = NULL;
+ SAFE_free(nxagentFailedToReconnectFonts.font);
+ SAFE_free(nxagentFailedToReconnectFonts.id);
FatalError("Font: font not reconnected memory allocation failed!.\n");
}
@@ -1050,7 +1043,7 @@ static void nxagentCleanCacheAfterReconnect(void)
{
if(CACHE_FSTRUCT(i) == NULL)
{
- XFree(CACHE_NAME(i));
+ SAFE_XFree(CACHE_NAME(i));
real_size--;
}
}
@@ -1223,11 +1216,8 @@ static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2)
static void nxagentFreeFailedToReconnectFonts(void)
{
- free(nxagentFailedToReconnectFonts.font);
- nxagentFailedToReconnectFonts.font = NULL;
-
- free(nxagentFailedToReconnectFonts.id);
- nxagentFailedToReconnectFonts.id = NULL;
+ SAFE_free(nxagentFailedToReconnectFonts.font);
+ SAFE_free(nxagentFailedToReconnectFonts.id);
nxagentFailedToReconnectFonts.size = 0;
nxagentFailedToReconnectFonts.index = 0;
@@ -1321,7 +1311,7 @@ Bool nxagentReconnectFailedFonts(void *p0)
nxagentListRemoteFonts("*", nxagentMaxFontNames);
XFreeFontPath(fontPaths);
- free(newFontPaths);
+ SAFE_free(newFontPaths);
return False;
}
@@ -1332,7 +1322,7 @@ Bool nxagentReconnectFailedFonts(void *p0)
XSetFontPath(nxagentDisplay, fontPaths, nPaths);
XFreeFontPath(fontPaths);
- free(newFontPaths);
+ SAFE_free(newFontPaths);
nxagentCleanCacheAfterReconnect();
@@ -1442,7 +1432,7 @@ void nxagentVerifySingleFontPath(char **dest, const char *fontDir)
if (rc == -1)
return;
- free(*dest);
+ SAFE_free(*dest);
*dest = tmppath;
tmppath = NULL;
}
@@ -1554,7 +1544,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo
fprintf(stderr, "nxagentLoadQueryFont: WARNING! Font not found '%s'.\n", name);
#endif
- free(fs);
+ SAFE_free(fs);
return (XFontStruct *) NULL;
}
@@ -1588,7 +1578,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo
fprintf(stderr, "nxagentLoadQueryFont: WARNING! Failed allocation of XFontProp.");
#endif
- free((char *) fs);
+ SAFE_free(fs);
return (XFontStruct *) NULL;
}
@@ -1622,18 +1612,17 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo
int nxagentFreeFont(XFontStruct *fs)
{
- if (fs -> per_char)
+ if (fs->per_char)
{
#ifdef USE_XF86BIGFONT
_XF86BigfontFreeFontMetrics(fs);
#else
- free ((char *) fs->per_char);
+ SAFE_free(fs->per_char);
#endif
}
- free (fs->properties);
-
- XFree(fs);
+ SAFE_free(fs->properties);
+ SAFE_XFree(fs);
return 1;
}
@@ -1769,7 +1758,7 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
MakeScalableFontNameError:
- free(scalableFontName);
+ SAFE_free(scalableFontName);
#ifdef DEBUG
fprintf(stderr, "nxagentMakeScalableFontName: Invalid font name.\n");
diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c
index 2fac2f100..df9c4ad0a 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/GC.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c
@@ -61,6 +61,7 @@ is" without express or implied warranty.
#include "Trap.h"
#include "Screen.h"
#include "Pixels.h"
+#include "Utils.h"
#include "../../fb/fb.h"
@@ -694,7 +695,7 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC -> clipOrg.x, pGC -> clipOrg.y,
pRects, nRects, Unsorted);
- free((char *) pRects);
+ SAFE_free(pRects);
}
break;
@@ -778,7 +779,7 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
pGC->clientClip = (void *) RegionFromRects(nRects,
(xRectangle *)pValue, type);
- free(pValue);
+ SAFE_free(pValue);
pValue = pGC->clientClip;
@@ -912,9 +913,8 @@ static void nxagentFreeGCRec(struct nxagentGCRec *t)
(void *) t, (void *) t -> gc);
#endif
- free(t -> gc);
-
- free(t);
+ SAFE_free(t -> gc);
+ SAFE_free(t);
}
static void nxagentRestoreGCRec(struct nxagentGCRec *t)
@@ -924,11 +924,11 @@ static void nxagentRestoreGCRec(struct nxagentGCRec *t)
(void*)t, (void*)t -> gc);
#endif
- free(nxagentGC(t -> pGC));
+ SAFE_free(nxagentGC(t -> pGC));
nxagentGC(t -> pGC) = t -> gc;
- free(t);
+ SAFE_free(t);
}
static void nxagentAddGCToList(GCPtr pGC)
@@ -1303,7 +1303,7 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC -> clipOrg.x, pGC -> clipOrg.y,
pRects, nRects, Unsorted);
- free((char *) pRects);
+ SAFE_free(pRects);
}
else
{
@@ -1374,7 +1374,7 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
pGC->clientClip = (void *) RegionFromRects(nRects,
(xRectangle *)pValue, type);
- free(pValue);
+ SAFE_free(pValue);
pValue = pGC->clientClip;
type = CT_REGION;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c
index beb9ef05f..6ab46c424 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c
@@ -57,6 +57,7 @@ is" without express or implied warranty.
#include "Holder.h"
#include "Args.h"
#include "Screen.h"
+#include "Utils.h"
#include "compext/Compext.h"
@@ -787,7 +788,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
srcx, srcy, width, height);
#endif
- free(data);
+ SAFE_free(data);
/*
* If the source is a shared memory pixmap, the
@@ -1007,7 +1008,7 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
srcx, srcy, width, height);
#endif
- free(data);
+ SAFE_free(data);
/*
* If the source is a shared memory pixmap, the
@@ -1545,7 +1546,7 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape,
RESET_GC_TRAP();
}
- free(newPoints);
+ SAFE_free(newPoints);
}
void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c
index a5e19724b..a7bacaf85 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Image.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c
@@ -455,7 +455,7 @@ FIXME: Here the split trap is always set and so the caching of
if (nxagentUnpackAlpha[resource] != NULL)
{
- free(nxagentUnpackAlpha[resource] -> data);
+ SAFE_free(nxagentUnpackAlpha[resource] -> data);
}
else if ((nxagentUnpackAlpha[resource] = malloc(sizeof(UnpackAlphaRec))) == NULL)
{
@@ -463,7 +463,7 @@ FIXME: Here the split trap is always set and so the caching of
fprintf(stderr, "nxagentSetUnpackAlpha: PANIC! Can't allocate data for the alpha structure.\n");
#endif
- free(data);
+ SAFE_free(data);
return;
}
@@ -483,7 +483,7 @@ FIXME: Here the split trap is always set and so the caching of
resource, size);
#endif
- free(data);
+ SAFE_free(data);
}
}
@@ -1567,20 +1567,20 @@ nxagentPutSubImageEnd:
nxagentImageStatistics.totalEncoded, nxagentImageStatistics.totalAdded);
#endif
- free(packedChecksum);
+ SAFE_free(packedChecksum);
if (packedImage != NULL)
{
if (packedImage -> data != NULL &&
packedImage -> data != plainImage -> data)
{
- free(packedImage -> data);
+ SAFE_free(packedImage -> data);
}
- free(packedImage);
+ SAFE_free(packedImage);
}
- free(plainImage);
+ SAFE_free(plainImage);
}
void nxagentGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
@@ -1634,11 +1634,8 @@ void nxagentResetAlphaCache(void)
{
if (nxagentUnpackAlpha[i])
{
- free(nxagentUnpackAlpha[i] -> data);
-
- free(nxagentUnpackAlpha[i]);
-
- nxagentUnpackAlpha[i] = NULL;
+ SAFE_free(nxagentUnpackAlpha[i] -> data);
+ SAFE_free(nxagentUnpackAlpha[i]);
}
}
}
@@ -1716,7 +1713,7 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio,
if (newImage -> data == NULL)
{
- free(newImage);
+ SAFE_free(newImage);
#ifdef PANIC
fprintf(stderr, "nxagentScaleImage: PANIC! Failed to create the target image data.\n");
@@ -1784,8 +1781,8 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio,
}
}
- free((char *) image -> obdata);
- free((char *) image);
+ SAFE_free(image -> obdata);
+ SAFE_free(image);
*pImage = newImage;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index 6fbc66481..b7ed38ca3 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -58,6 +58,7 @@ is" without express or implied warranty.
#include "Options.h"
#include "Error.h"
#include "Init.h"
+#include "Utils.h"
#include "compext/Compext.h"
@@ -657,7 +658,7 @@ N/A
{
keymap[i] = keymap64[i];
}
- XFree(keymap64);
+ SAFE_XFree(keymap64);
}
#else /* #ifdef _XSERVER64 */
@@ -762,7 +763,7 @@ XkbError:
#ifdef TEST
fprintf(stderr, "%s: changing nxagentKeyboard from [null/null] to [clone].\n", __func__);
#endif
- free(nxagentKeyboard);
+ SAFE_free(nxagentKeyboard);
nxagentKeyboard = strdup("clone");
}
@@ -809,7 +810,7 @@ XkbError:
layout = strdup(strsep(&tmp, sep));
variant = strdup(strsep(&tmp, sep));
options = strdup(strsep(&tmp, sep));
- free(rmlvo);
+ SAFE_free(rmlvo);
}
else
{
@@ -864,11 +865,11 @@ XkbError:
/* Only setup keycode conversion if we are NOT in clone mode */
if (nxagentKeyboard && (strcmp(nxagentKeyboard, "clone") == 0))
{
- free(rules); rules = strdup(nxagentRemoteRules);
- free(model); model = strdup(nxagentRemoteModel);
- free(layout); layout = strdup(nxagentRemoteLayout);
- free(variant); variant = strdup(nxagentRemoteVariant);
- free(options); options = strdup(nxagentRemoteOptions);
+ SAFE_free(rules); rules = strdup(nxagentRemoteRules);
+ SAFE_free(model); model = strdup(nxagentRemoteModel);
+ SAFE_free(layout); layout = strdup(nxagentRemoteLayout);
+ SAFE_free(variant); variant = strdup(nxagentRemoteVariant);
+ SAFE_free(options); options = strdup(nxagentRemoteOptions);
/*
* when cloning we do not want X2Go to set the keyboard
* via a keyboard file generated by nxagent. The defined
@@ -947,9 +948,9 @@ XkbError:
NXShadowInitKeymap(&(pDev->key->curKeySyms));
}
- free(rules);
- free(variant);
- free(options);
+ SAFE_free(rules);
+ SAFE_free(variant);
+ SAFE_free(options);
}
if (xkb)
@@ -958,8 +959,8 @@ XkbError:
xkb = NULL;
}
- free(model);
- free(layout);
+ SAFE_free(model);
+ SAFE_free(layout);
#endif
#ifdef WATCH
@@ -980,9 +981,9 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio
#endif
#ifdef _XSERVER64
- free(keymap);
+ SAFE_free(keymap);
#else
- XFree(keymap);
+ SAFE_XFree(keymap);
#endif
break;
case DEVICE_ON:
@@ -1182,7 +1183,7 @@ int nxagentResetKeyboard(void)
nxagentFreeKeyboardDeviceData(devBackup);
- free(devBackup);
+ SAFE_free(devBackup);
return 1;
}
@@ -1315,18 +1316,15 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev)
}
#endif
- free(dev->key->curKeySyms.map);
- free(dev->key->modifierKeyMap);
- free(dev->key);
-
- dev->key = NULL;
+ SAFE_free(dev->key->curKeySyms.map);
+ SAFE_free(dev->key->modifierKeyMap);
+ SAFE_free(dev->key);
}
if (dev->focus)
{
- free(dev->focus->trace);
- free(dev->focus);
- dev->focus = NULL;
+ SAFE_free(dev->focus->trace);
+ SAFE_free(dev->focus);
}
if (dev->kbdfeed)
@@ -1338,7 +1336,7 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev)
if (k->xkb_sli)
XkbFreeSrvLedInfo(k->xkb_sli);
#endif
- free(k);
+ SAFE_free(k);
}
dev->kbdfeed = NULL;
}
@@ -1571,11 +1569,11 @@ void nxagentTuneXkbWrapper(void)
void nxagentXkbClearNames(void)
{
- free(nxagentRemoteRules); nxagentRemoteRules = NULL;
- free(nxagentRemoteModel); nxagentRemoteModel = NULL;
- free(nxagentRemoteLayout); nxagentRemoteLayout = NULL;
- free(nxagentRemoteVariant); nxagentRemoteVariant = NULL;
- free(nxagentRemoteOptions); nxagentRemoteOptions = NULL;
+ SAFE_free(nxagentRemoteRules);
+ SAFE_free(nxagentRemoteModel);
+ SAFE_free(nxagentRemoteLayout);
+ SAFE_free(nxagentRemoteVariant);
+ SAFE_free(nxagentRemoteOptions);
}
static void nxagentXkbGetNames(void)
@@ -1618,7 +1616,7 @@ static void nxagentXkbGetNames(void)
{
if (data)
{
- XFree(data);
+ SAFE_XFree(data);
return;
}
}
@@ -1655,7 +1653,7 @@ static void nxagentXkbGetNames(void)
name += strlen(name) + 1;
}
- XFree(data);
+ SAFE_XFree(data);
return;
}
@@ -1686,12 +1684,12 @@ static char* getKeyboardFilePath(void)
{
if ((asprintf(&keyboard_file_path, "%s/keyboard", sessionpath) == -1))
{
- free(sessionpath);
+ SAFE_free(sessionpath);
FatalError("malloc for keyboard file path failed.");
}
else
{
- free(sessionpath);
+ SAFE_free(sessionpath);
}
}
else
@@ -1720,7 +1718,7 @@ static void nxagentWriteKeyboardDir(void)
{
fprintf(stderr, "Info: keyboard blocking directory created: '%s'\n", keyboard_file_path);
}
- free(keyboard_file_path);
+ SAFE_free(keyboard_file_path);
}
}
@@ -1748,7 +1746,7 @@ static void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, cha
int save_err = errno;
fprintf(stderr, "Error: keyboard file not created: %s\n", strerror(save_err));
}
- free(keyboard_file_path);
+ SAFE_free(keyboard_file_path);
}
}
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
index 966b4f842..fe7e10d82 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
@@ -294,7 +294,7 @@ void nxagentInitKeystrokes(Bool force)
if (force) {
if (map != default_map)
{
- free(map);
+ SAFE_free(map);
map = default_map;
}
fprintf(stderr, "Info: re-reading keystrokes configuration\n");
@@ -414,7 +414,7 @@ void nxagentInitKeystrokes(Bool force)
#endif
filename = NULL;
}
- free(homepath);
+ SAFE_free(homepath);
if (map == default_map)
{
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c
index 653426ebb..58fea6c05 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c
@@ -49,6 +49,7 @@
#include "Events.h"
#include "Holder.h"
#include "Args.h"
+#include "Utils.h"
#include "compext/Compext.h"
#include <nx/NXpack.h>
@@ -501,7 +502,7 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap)
FreeResource(pPixmapPriv -> mid, RT_NONE);
}
- free(pPixmap);
+ SAFE_free(pPixmap);
return True;
}
@@ -1092,7 +1093,7 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap)
{
FatalError("XGetImage: Failed.\n");
- free(data);
+ SAFE_free(data);
return False;
}
@@ -1168,7 +1169,7 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap)
XDestroyImage(image);
}
- free(data);
+ SAFE_free(data);
}
else
{
@@ -1265,7 +1266,7 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict,
nxagentPutImage(pDrawable, pGC, depth, xPict, yPict,
width, height, 0, format, data);
- free(data);
+ SAFE_free(data);
}
#ifdef WARNING
else
@@ -1413,7 +1414,7 @@ FIXME: If the pixmap has a different depth from the window, the
fprintf(stderr, "nxagentPixmapOnShadowDisplay: XCreateImage failed.\n");
#endif
- free(data);
+ SAFE_free(data);
return False;
}
@@ -1572,7 +1573,7 @@ Bool nxagentFbOnShadowDisplay(void)
fprintf(stderr, "nxagentFbOnShadowDisplay: XCreateImage failed.\n");
#endif
- free(data);
+ SAFE_free(data);
return False;
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
index c56d74236..e29fc3200 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
@@ -53,6 +53,7 @@
#include "Splash.h"
#include "Error.h"
#include "Keystroke.h"
+#include "Utils.h"
#ifdef XKB
#include "XKBsrv.h"
@@ -448,8 +449,7 @@ Bool nxagentReconnectSession(void)
return 0;
}
- free(nxagentKeyboard);
- nxagentKeyboard = NULL;
+ SAFE_free(nxagentKeyboard);
}
nxagentSaveOptions();
@@ -464,7 +464,7 @@ Bool nxagentReconnectSession(void)
fprintf(stderr, "nxagentReconnect: changing nxagentKeyboard from [null/null] to [clone].\n");
#endif
- free(nxagentKeyboard);
+ SAFE_free(nxagentKeyboard);
nxagentKeyboard = strdup("clone");
}
@@ -635,8 +635,7 @@ Bool nxagentReconnectSession(void)
nxagentXkbState.Initialized = 0;
- free(nxagentOldKeyboard);
- nxagentOldKeyboard = NULL;
+ SAFE_free(nxagentOldKeyboard);
nxagentInitPointerMap();
@@ -760,8 +759,7 @@ nxagentReconnectError:
nxagentDisconnectDisplay();
}
- free(nxagentOldKeyboard);
- nxagentOldKeyboard = NULL;
+ SAFE_free(nxagentOldKeyboard);
return 0;
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c
index 9d91b1ff1..ebc1fe287 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Render.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c
@@ -45,6 +45,7 @@
#include "Drawable.h"
#include "Trap.h"
#include "Args.h"
+#include "Utils.h"
#define Atom XlibAtom
#define Pixmap XlibPixmap
@@ -2528,7 +2529,7 @@ void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi,
if (normalizedImages != images)
{
- free(normalizedImages);
+ SAFE_free(normalizedImages);
}
#ifdef DEBUG
@@ -2636,7 +2637,7 @@ FIXME: Is this useful or just a waste of bandwidth?
nparams);
#endif
- free(szFilter);
+ SAFE_free(szFilter);
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
index c2611c194..6908799b6 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
@@ -281,10 +281,7 @@ Bool nxagentRootlessTreesMatch(void)
}
}
- if (children_return)
- {
- XFree(children_return);
- }
+ SAFE_XFree(children_return);
return treesMatch;
}
@@ -332,7 +329,7 @@ void nxagentRootlessRestack(unsigned long children[], unsigned int nchildren)
if (!ntoplevel)
{
- free(toplevel);
+ SAFE_free(toplevel);
return;
}
@@ -397,7 +394,7 @@ void nxagentRootlessRestack(unsigned long children[], unsigned int nchildren)
#endif
- free(toplevel);
+ SAFE_free(toplevel);
return;
}
@@ -818,7 +815,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
if (freeMem)
{
- free(output);
+ SAFE_free(output);
}
return export;
@@ -1131,7 +1128,7 @@ void nxagentImportProperty(Window window,
if (freeMem)
{
- free(output);
+ SAFE_free(output);
}
return;
@@ -1183,7 +1180,7 @@ void nxagentRemovePropertyFromList(void)
nxagentPropertyList.last = NULL;
}
- free(tmp);
+ SAFE_free(tmp);
}
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c
index 93110f782..434389504 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c
@@ -302,8 +302,7 @@ Bool nxagentIsParentOf(Display *d, XlibWindow possible_parent, XlibWindow candid
if (XQueryTree(d, candidate, &root, &parent, &children, &num_children))
{
- if (children)
- XFree((char *)children);
+ SAFE_XFree(children);
#ifdef TEST
fprintf(stderr, "%s: parent of full screen window [%p] root [%p] possible_parent [%p] candidate [%p]\n", __func__, parent, root, possible_parent, candidate);
@@ -484,11 +483,8 @@ Window nxagentCreateIconWindow(void)
window_name, window_name,
NULL , 0 , sizeHints, wmHints, NULL);
- if (sizeHints)
- XFree(sizeHints);
-
- if (wmHints)
- XFree(wmHints);
+ SAFE_XFree(sizeHints);
+ SAFE_XFree(wmHints);
/*
* Enable events from the icon window.
@@ -889,10 +885,9 @@ void freeDepths(DepthPtr depths, int num)
#ifdef DEBUG
fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, depths[i].depth, i, (void*) depths[i].vids);
#endif
- free(depths[i].vids);
- depths[i].vids = NULL;
+ SAFE_free(depths[i].vids);
}
- free(depths);
+ SAFE_free(depths);
}
Bool nxagentOpenScreen(ScreenPtr pScreen,
@@ -1387,7 +1382,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
if (!pFrameBufferBits)
{
freeDepths(depths, numDepths);
- free(visuals);
+ SAFE_free(visuals);
return FALSE;
}
@@ -1410,7 +1405,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
monitorResolution, monitorResolution, PixmapBytePad(nxagentOption(RootWidth), rootDepth), bitsPerPixel))
{
freeDepths(depths, numDepths);
- free(visuals);
+ SAFE_free(visuals);
return FALSE;
}
@@ -1451,7 +1446,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
pScreen -> numDepths = numDepths;
pScreen -> rootDepth = rootDepth;
- free(pScreen -> visuals);
+ SAFE_free(pScreen -> visuals);
pScreen -> visuals = visuals;
pScreen -> numVisuals = numVisuals;
pScreen -> rootVisual = defaultVisual;
@@ -1892,8 +1887,8 @@ N/A
hint.res_class = strdup("NXAgent");
}
XSetClassHint(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &hint);
- free(hint.res_name);
- free(hint.res_class);
+ SAFE_free(hint.res_name);
+ SAFE_free(hint.res_class);
}
if (nxagentOption(Fullscreen))
@@ -1977,17 +1972,8 @@ N/A
nxagentWindowName,
argv , argc , sizeHints, wmHints, NULL);
- if (sizeHints)
- {
- XFree(sizeHints);
- sizeHints = NULL;
- }
-
- if (wmHints)
- {
- XFree(wmHints);
- wmHints = NULL;
- }
+ SAFE_XFree(sizeHints);
+ SAFE_XFree(wmHints);
/*
* Clear the window but let it unmapped. We'll map it
@@ -2199,9 +2185,9 @@ Bool nxagentCloseScreen(ScreenPtr pScreen)
* Free the frame buffer.
*/
- free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr);
- free(pScreen->devPrivate);pScreen->devPrivate = NULL;
- free(pScreen->visuals); pScreen->visuals = NULL;
+ SAFE_free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr);
+ SAFE_free(pScreen->devPrivate);
+ SAFE_free(pScreen->visuals);
fbCloseScreen(pScreen);
@@ -3158,7 +3144,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr
length = nxagentImageLength(width, height, ZPixmap, 0, nxagentMasterDepth);
- free(tBuffer);
+ SAFE_free(tBuffer);
tBuffer = malloc(length);
@@ -3215,7 +3201,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr
RegionUnion(&nxagentShadowUpdateRegion, &nxagentShadowUpdateRegion, &updateRegion);
}
- free(tBuffer);
+ SAFE_free(tBuffer);
RegionUninit(&updateRegion);
}
@@ -3433,7 +3419,7 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height,
cBuffer = (unsigned char *) *buffer;
*buffer = (char *) icBuffer;
- free(cBuffer);
+ SAFE_free(cBuffer);
}
#ifdef NXAGENT_ARTSD
@@ -3616,7 +3602,7 @@ FIXME: The port information is not used at the moment and produces a
strlen(local_buf), local_buf, 1);
}
- free(local_buf);
+ SAFE_free(local_buf);
}
}
}
@@ -4040,7 +4026,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
#endif
number = 1;
- free(screeninfo);
+ SAFE_free(screeninfo);
if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) {
return FALSE;
@@ -4309,8 +4295,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
}
/* release allocated memory */
- free(screeninfo);
- screeninfo = NULL;
+ SAFE_free(screeninfo);
#ifdef DEBUG
for (i = 0; i < pScrPriv->numCrtcs; i++) {
@@ -4425,7 +4410,7 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg,
XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted);
- free((char *) pRects);
+ SAFE_free(pRects);
extents = *RegionExtents(&cleanRegion);
@@ -4571,7 +4556,7 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg,
XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted);
- free(pRects);
+ SAFE_free(pRects);
extents = *RegionExtents(clipRegion);
@@ -4651,7 +4636,7 @@ void nxagentSetWMNormalHints(int screen, int width, int height)
XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[screen], sizeHints);
- XFree(sizeHints);
+ SAFE_XFree(sizeHints);
}
/*
@@ -4670,7 +4655,7 @@ void nxagentSetWMNormalHintsMaxsize(ScreenPtr pScreen, int maxwidth, int maxheig
sizeHints->max_height = maxheight;
XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum],
sizeHints);
- XFree(sizeHints);
+ SAFE_XFree(sizeHints);
}
}
@@ -4811,7 +4796,7 @@ FIXME
fprintf(stderr, "nxagentShowPixmap: XGetImage failed.\n");
#endif
- free(data);
+ SAFE_free(data);
return;
}
@@ -4844,7 +4829,7 @@ FIXME
XDestroyImage(image);
}
- free(data);
+ SAFE_free(data);
/*
FIXME
@@ -4896,7 +4881,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc,
fprintf(stderr, "nxagentFbRestoreArea: XGetImage failed.\n");
#endif
- free(data);
+ SAFE_free(data);
return;
}
@@ -4956,7 +4941,7 @@ FIXME
/*
FIXME
- free(data);
+ SAFE_free(data);
*/
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Utils.h b/nx-X11/programs/Xserver/hw/nxagent/Utils.h
index c0ad03345..0aebda839 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Utils.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Utils.h
@@ -45,5 +45,6 @@ static inline const char * validateString(const char *str) {
}
#define SAFE_XFree(what) do {if (what) {XFree(what); what = NULL;}} while (0)
+#define SAFE_free(what) do {free(what); what = NULL;} while (0)
#endif /* __Utils_H__ */
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c
index 192feec40..59b33b6be 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Window.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c
@@ -63,6 +63,7 @@
#include "Init.h"
#include "Composite.h"
#include "Events.h"
+#include "Utils.h"
#include <nx/NX.h>
#include "compext/Compext.h"
@@ -1430,10 +1431,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask)
fprintf(stderr, "nxagentConfigureWindow: Failed QueryTree request.\n ");
}
- if (children_return)
- {
- XFree(children_return);
- }
+ SAFE_XFree(children_return);
}
#endif
}
@@ -3129,7 +3127,7 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer
&hints);
#ifdef _XSERVER64
- free(data64);
+ SAFE_free(data64);
#endif
}
}
@@ -3376,7 +3374,7 @@ Bool nxagentCheckWindowIntegrity(WindowPtr pWin)
XDestroyImage(image);
}
- free(data);
+ SAFE_free(data);
}
else
{
@@ -3465,14 +3463,14 @@ void nxagentFlushConfigureWindow(void)
if (index == nxagentConfiguredWindowList)
{
- free(index);
+ SAFE_free(index);
break;
}
else
{
ConfiguredWindowStruct *tmp = index;
index = index -> prev;
- free(tmp);
+ SAFE_free(tmp);
}
}
@@ -3622,16 +3620,14 @@ void nxagentDeleteConfiguredWindow(WindowPtr pWin)
{
if (index -> prev == NULL && index -> next == NULL)
{
- free(nxagentConfiguredWindowList);
- nxagentConfiguredWindowList = NULL;
-
+ SAFE_free(nxagentConfiguredWindowList);
return;
}
else if (index -> prev == NULL)
{
tmp = nxagentConfiguredWindowList;
index = nxagentConfiguredWindowList = tmp -> next;
- free(tmp);
+ SAFE_free(tmp);
nxagentConfiguredWindowList -> prev = NULL;
continue;
@@ -3640,7 +3636,7 @@ void nxagentDeleteConfiguredWindow(WindowPtr pWin)
{
tmp = index;
index = index -> prev;
- free(tmp);
+ SAFE_free(tmp);
index -> next = NULL;
return;
@@ -3651,7 +3647,7 @@ void nxagentDeleteConfiguredWindow(WindowPtr pWin)
index = index -> next;
previous -> next = index;
index -> prev = previous;
- free(tmp);
+ SAFE_free(tmp);
continue;
}
@@ -3693,16 +3689,14 @@ void nxagentDeleteStaticResizedWindow(unsigned long sequence)
{
if (index -> prev == NULL && index -> next == NULL)
{
- free(nxagentStaticResizedWindowList);
- nxagentStaticResizedWindowList = NULL;
-
+ SAFE_free(nxagentStaticResizedWindowList);
return;
}
else if (index -> prev == NULL)
{
tmp = nxagentStaticResizedWindowList;
index = nxagentStaticResizedWindowList = tmp -> next;
- free(tmp);
+ SAFE_free(tmp);
nxagentStaticResizedWindowList -> prev = NULL;
continue;
@@ -3711,7 +3705,7 @@ void nxagentDeleteStaticResizedWindow(unsigned long sequence)
{
tmp = index;
index = index -> prev;
- free(tmp);
+ SAFE_free(tmp);
index -> next = NULL;
return;
@@ -3722,7 +3716,7 @@ void nxagentDeleteStaticResizedWindow(unsigned long sequence)
index = index -> next;
previous -> next = index;
index -> prev = previous;
- free(tmp);
+ SAFE_free(tmp);
continue;
}
@@ -3855,8 +3849,7 @@ int nxagentRemoveItemBSPixmapList(unsigned long pixmapId)
if ((nxagentBSPixmapList[i] != NULL) &&
(nxagentBSPixmapList[i] -> storingPixmapId == pixmapId))
{
- free(nxagentBSPixmapList[i]);
- nxagentBSPixmapList[i] = NULL;
+ SAFE_free(nxagentBSPixmapList[i]);
if (i < BSPIXMAPLIMIT - 1)
{
@@ -3894,8 +3887,7 @@ int nxagentEmptyBSPixmapList(void)
{
for (int i = 0; i < BSPIXMAPLIMIT; i++)
{
- free(nxagentBSPixmapList[i]);
- nxagentBSPixmapList[i] = NULL;
+ SAFE_free(nxagentBSPixmapList[i]);
}
return 1;