Commit fd4fa4e9 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Keyboard.c: use SAFE_XFree and SAFE_free

parent 15653343
...@@ -58,6 +58,7 @@ is" without express or implied warranty. ...@@ -58,6 +58,7 @@ is" without express or implied warranty.
#include "Options.h" #include "Options.h"
#include "Error.h" #include "Error.h"
#include "Init.h" #include "Init.h"
#include "Utils.h"
#include "compext/Compext.h" #include "compext/Compext.h"
...@@ -657,7 +658,7 @@ N/A ...@@ -657,7 +658,7 @@ N/A
{ {
keymap[i] = keymap64[i]; keymap[i] = keymap64[i];
} }
XFree(keymap64); SAFE_XFree(keymap64);
} }
#else /* #ifdef _XSERVER64 */ #else /* #ifdef _XSERVER64 */
...@@ -762,7 +763,7 @@ XkbError: ...@@ -762,7 +763,7 @@ XkbError:
#ifdef TEST #ifdef TEST
fprintf(stderr, "%s: changing nxagentKeyboard from [null/null] to [clone].\n", __func__); fprintf(stderr, "%s: changing nxagentKeyboard from [null/null] to [clone].\n", __func__);
#endif #endif
free(nxagentKeyboard); SAFE_free(nxagentKeyboard);
nxagentKeyboard = strdup("clone"); nxagentKeyboard = strdup("clone");
} }
...@@ -809,7 +810,7 @@ XkbError: ...@@ -809,7 +810,7 @@ XkbError:
layout = strdup(strsep(&tmp, sep)); layout = strdup(strsep(&tmp, sep));
variant = strdup(strsep(&tmp, sep)); variant = strdup(strsep(&tmp, sep));
options = strdup(strsep(&tmp, sep)); options = strdup(strsep(&tmp, sep));
free(rmlvo); SAFE_free(rmlvo);
} }
else else
{ {
...@@ -864,11 +865,11 @@ XkbError: ...@@ -864,11 +865,11 @@ XkbError:
/* Only setup keycode conversion if we are NOT in clone mode */ /* Only setup keycode conversion if we are NOT in clone mode */
if (nxagentKeyboard && (strcmp(nxagentKeyboard, "clone") == 0)) if (nxagentKeyboard && (strcmp(nxagentKeyboard, "clone") == 0))
{ {
free(rules); rules = strdup(nxagentRemoteRules); SAFE_free(rules); rules = strdup(nxagentRemoteRules);
free(model); model = strdup(nxagentRemoteModel); SAFE_free(model); model = strdup(nxagentRemoteModel);
free(layout); layout = strdup(nxagentRemoteLayout); SAFE_free(layout); layout = strdup(nxagentRemoteLayout);
free(variant); variant = strdup(nxagentRemoteVariant); SAFE_free(variant); variant = strdup(nxagentRemoteVariant);
free(options); options = strdup(nxagentRemoteOptions); SAFE_free(options); options = strdup(nxagentRemoteOptions);
/* /*
* when cloning we do not want X2Go to set the keyboard * when cloning we do not want X2Go to set the keyboard
* via a keyboard file generated by nxagent. The defined * via a keyboard file generated by nxagent. The defined
...@@ -947,9 +948,9 @@ XkbError: ...@@ -947,9 +948,9 @@ XkbError:
NXShadowInitKeymap(&(pDev->key->curKeySyms)); NXShadowInitKeymap(&(pDev->key->curKeySyms));
} }
free(rules); SAFE_free(rules);
free(variant); SAFE_free(variant);
free(options); SAFE_free(options);
} }
if (xkb) if (xkb)
...@@ -958,8 +959,8 @@ XkbError: ...@@ -958,8 +959,8 @@ XkbError:
xkb = NULL; xkb = NULL;
} }
free(model); SAFE_free(model);
free(layout); SAFE_free(layout);
#endif #endif
#ifdef WATCH #ifdef WATCH
...@@ -980,9 +981,9 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio ...@@ -980,9 +981,9 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio
#endif #endif
#ifdef _XSERVER64 #ifdef _XSERVER64
free(keymap); SAFE_free(keymap);
#else #else
XFree(keymap); SAFE_XFree(keymap);
#endif #endif
break; break;
case DEVICE_ON: case DEVICE_ON:
...@@ -1182,7 +1183,7 @@ int nxagentResetKeyboard(void) ...@@ -1182,7 +1183,7 @@ int nxagentResetKeyboard(void)
nxagentFreeKeyboardDeviceData(devBackup); nxagentFreeKeyboardDeviceData(devBackup);
free(devBackup); SAFE_free(devBackup);
return 1; return 1;
} }
...@@ -1315,18 +1316,15 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) ...@@ -1315,18 +1316,15 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev)
} }
#endif #endif
free(dev->key->curKeySyms.map); SAFE_free(dev->key->curKeySyms.map);
free(dev->key->modifierKeyMap); SAFE_free(dev->key->modifierKeyMap);
free(dev->key); SAFE_free(dev->key);
dev->key = NULL;
} }
if (dev->focus) if (dev->focus)
{ {
free(dev->focus->trace); SAFE_free(dev->focus->trace);
free(dev->focus); SAFE_free(dev->focus);
dev->focus = NULL;
} }
if (dev->kbdfeed) if (dev->kbdfeed)
...@@ -1338,7 +1336,7 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) ...@@ -1338,7 +1336,7 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev)
if (k->xkb_sli) if (k->xkb_sli)
XkbFreeSrvLedInfo(k->xkb_sli); XkbFreeSrvLedInfo(k->xkb_sli);
#endif #endif
free(k); SAFE_free(k);
} }
dev->kbdfeed = NULL; dev->kbdfeed = NULL;
} }
...@@ -1571,11 +1569,11 @@ void nxagentTuneXkbWrapper(void) ...@@ -1571,11 +1569,11 @@ void nxagentTuneXkbWrapper(void)
void nxagentXkbClearNames(void) void nxagentXkbClearNames(void)
{ {
free(nxagentRemoteRules); nxagentRemoteRules = NULL; SAFE_free(nxagentRemoteRules);
free(nxagentRemoteModel); nxagentRemoteModel = NULL; SAFE_free(nxagentRemoteModel);
free(nxagentRemoteLayout); nxagentRemoteLayout = NULL; SAFE_free(nxagentRemoteLayout);
free(nxagentRemoteVariant); nxagentRemoteVariant = NULL; SAFE_free(nxagentRemoteVariant);
free(nxagentRemoteOptions); nxagentRemoteOptions = NULL; SAFE_free(nxagentRemoteOptions);
} }
static void nxagentXkbGetNames(void) static void nxagentXkbGetNames(void)
...@@ -1618,7 +1616,7 @@ static void nxagentXkbGetNames(void) ...@@ -1618,7 +1616,7 @@ static void nxagentXkbGetNames(void)
{ {
if (data) if (data)
{ {
XFree(data); SAFE_XFree(data);
return; return;
} }
} }
...@@ -1655,7 +1653,7 @@ static void nxagentXkbGetNames(void) ...@@ -1655,7 +1653,7 @@ static void nxagentXkbGetNames(void)
name += strlen(name) + 1; name += strlen(name) + 1;
} }
XFree(data); SAFE_XFree(data);
return; return;
} }
...@@ -1686,12 +1684,12 @@ static char* getKeyboardFilePath(void) ...@@ -1686,12 +1684,12 @@ static char* getKeyboardFilePath(void)
{ {
if ((asprintf(&keyboard_file_path, "%s/keyboard", sessionpath) == -1)) if ((asprintf(&keyboard_file_path, "%s/keyboard", sessionpath) == -1))
{ {
free(sessionpath); SAFE_free(sessionpath);
FatalError("malloc for keyboard file path failed."); FatalError("malloc for keyboard file path failed.");
} }
else else
{ {
free(sessionpath); SAFE_free(sessionpath);
} }
} }
else else
...@@ -1720,7 +1718,7 @@ static void nxagentWriteKeyboardDir(void) ...@@ -1720,7 +1718,7 @@ static void nxagentWriteKeyboardDir(void)
{ {
fprintf(stderr, "Info: keyboard blocking directory created: '%s'\n", keyboard_file_path); 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 ...@@ -1748,7 +1746,7 @@ static void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, cha
int save_err = errno; int save_err = errno;
fprintf(stderr, "Error: keyboard file not created: %s\n", strerror(save_err)); fprintf(stderr, "Error: keyboard file not created: %s\n", strerror(save_err));
} }
free(keyboard_file_path); SAFE_free(keyboard_file_path);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment