aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/dix
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2017-03-02 11:01:43 +0100
committerMihai Moldovan <ionic@ionic.de>2017-03-02 11:01:43 +0100
commit554a6fa760de47c497abcc91bb5f1f9b2756a407 (patch)
treef59b0c8ddd14dc414c952710b2010477107cde06 /nx-X11/programs/Xserver/dix
parentf42d36fb73e096113a948a04279b752689f157bc (diff)
parent9c3669c6b7ff19013b3684bb74d98ec3d121e329 (diff)
downloadnx-libs-554a6fa760de47c497abcc91bb5f1f9b2756a407.tar.gz
nx-libs-554a6fa760de47c497abcc91bb5f1f9b2756a407.tar.bz2
nx-libs-554a6fa760de47c497abcc91bb5f1f9b2756a407.zip
Merge branch 'sunweaver-pr/constify-atom-name-strings' into 3.6.x
Attributes GH PR #363: https://github.com/ArcticaProject/nx-libs/pull/363
Diffstat (limited to 'nx-X11/programs/Xserver/dix')
-rw-r--r--nx-X11/programs/Xserver/dix/atom.c13
-rw-r--r--nx-X11/programs/Xserver/dix/dispatch.c2
2 files changed, 7 insertions, 8 deletions
diff --git a/nx-X11/programs/Xserver/dix/atom.c b/nx-X11/programs/Xserver/dix/atom.c
index fdacb2a6b..d569c2314 100644
--- a/nx-X11/programs/Xserver/dix/atom.c
+++ b/nx-X11/programs/Xserver/dix/atom.c
@@ -62,7 +62,7 @@ typedef struct _Node {
struct _Node *left, *right;
Atom a;
unsigned int fingerPrint;
- char *string;
+ const char *string;
} NodeRec, *NodePtr;
static Atom lastAtom = None;
@@ -116,13 +116,11 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
}
else
{
- nd->string = (char *) malloc(len + 1);
+ nd->string = strndup(string, len);
if (!nd->string) {
free(nd);
return BAD_RESOURCE;
}
- strncpy(nd->string, string, (int)len);
- nd->string[len] = 0;
}
if ((lastAtom + 1) >= tableLength) {
NodePtr *table;
@@ -131,7 +129,8 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
tableLength * (2 * sizeof(NodePtr)));
if (!table) {
if (nd->string != string)
- free(nd->string);
+ /* nd->string has been strdup'ed */
+ free((char *)nd->string);
free(nd);
return BAD_RESOURCE;
}
@@ -155,7 +154,7 @@ ValidAtom(Atom atom)
return (atom != None) && (atom <= lastAtom);
}
-char *
+const char *
NameForAtom(Atom atom)
{
NodePtr node;
@@ -178,7 +177,7 @@ FreeAtom(NodePtr patom)
if(patom->right)
FreeAtom(patom->right);
if (patom->a > XA_LAST_PREDEFINED)
- free(patom->string);
+ free((char *)patom->string);
free(patom);
}
diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c
index 044ba1c4b..8313d5bff 100644
--- a/nx-X11/programs/Xserver/dix/dispatch.c
+++ b/nx-X11/programs/Xserver/dix/dispatch.c
@@ -886,7 +886,7 @@ ProcInternAtom(register ClientPtr client)
int
ProcGetAtomName(register ClientPtr client)
{
- char *str;
+ const char *str;
xGetAtomNameReply reply;
int len;
REQUEST(xResourceReq);