summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/XpAttr.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/XpAttr.c b/src/XpAttr.c
index 6818daf..665e2e8 100644
--- a/src/XpAttr.c
+++ b/src/XpAttr.c
@@ -48,6 +48,7 @@
#include <stdio.h>
#include <sys/stat.h>
+#include <limits.h>
char *
XpGetAttributes (
@@ -83,17 +84,18 @@ XpGetAttributes (
/*
* Read pool and return to caller.
*/
- buf = Xmalloc( (unsigned) rep.stringLen + 1 );
+ if (rep.stringLen < INT_MAX)
+ buf = Xmalloc(rep.stringLen + 1);
+ else
+ buf = NULL;
if (!buf) {
- UnlockDisplay(dpy);
- SyncHandle();
- return( (char *) NULL ); /* malloc error */
+ _XEatDataWords(dpy, rep.length);
+ }
+ else {
+ _XReadPad (dpy, (char *) buf, rep.stringLen );
+ buf[rep.stringLen] = 0;
}
-
- _XReadPad (dpy, (char *) buf, (long) rep.stringLen );
-
- buf[rep.stringLen] = 0;
UnlockDisplay(dpy);
SyncHandle();
@@ -144,18 +146,18 @@ XpGetOneAttribute (
/*
* Read variable answer.
*/
- buf = Xmalloc( (unsigned) rep.valueLen + 1 );
+ if (rep.valueLen < INT_MAX)
+ buf = Xmalloc(rep.valueLen + 1);
+ else
+ buf = NULL;
if (!buf) {
- UnlockDisplay(dpy);
- SyncHandle();
- return( (char *) NULL ); /* malloc error */
+ _XEatDataWords(dpy, rep.length);
+ }
+ else {
+ _XReadPad (dpy, (char *) buf, rep.valueLen);
+ buf[rep.valueLen] = 0;
}
-
- buf[rep.valueLen] = 0;
-
- _XReadPad (dpy, (char *) buf, (long) rep.valueLen );
- buf[rep.valueLen] = 0;
UnlockDisplay(dpy);
SyncHandle();