summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2007-06-06 14:36:43 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2007-06-06 14:36:43 -0700
commit931675017dd28ccca8353abeff3055f0c47bc3b2 (patch)
tree84ded6c204292aeb5e16cbbe3b9e91d20a097eec /src
parentdab4830b8db0d3cf5db5e96b2b870e94a48330bc (diff)
downloadxorg-lib-libXtst-931675017dd28ccca8353abeff3055f0c47bc3b2.tar.gz
Coverity #578/579: Don't leak memory if one malloc fails but other succeeds
(Unlikely to happen, since the smaller malloc was first, but still possible.)
Diffstat (limited to 'src')
-rw-r--r--src/XRecord.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/XRecord.c b/src/XRecord.c
index 191a504..5d2623e 100644
--- a/src/XRecord.c
+++ b/src/XRecord.c
@@ -462,7 +462,9 @@ XRecordGetContext(dpy, context, state_return)
{
client_inf = (XRecordClientInfo **) Xcalloc(count, sizeof(XRecordClientInfo*));
ret->client_info = client_inf;
- client_inf_str = (XRecordClientInfo *) Xmalloc(count*sizeof(XRecordClientInfo));
+ if (client_inf != NULL) {
+ client_inf_str = (XRecordClientInfo *) Xmalloc(count*sizeof(XRecordClientInfo));
+ }
if (!client_inf || !client_inf_str)
{
for(i = 0; i < count; i++)
@@ -485,7 +487,10 @@ XRecordGetContext(dpy, context, state_return)
if (xclient_inf.nRanges)
{
client_inf_str[i].ranges = (XRecordRange**) Xcalloc(xclient_inf.nRanges, sizeof(XRecordRange*));
- ranges = (XRecordRange*) Xmalloc(xclient_inf.nRanges * sizeof(XRecordRange));
+ if (client_inf_str[i].ranges != NULL) {
+ ranges = (XRecordRange*)
+ Xmalloc(xclient_inf.nRanges * sizeof(XRecordRange));
+ }
if (!client_inf_str[i].ranges || !ranges) {
/* XXX eat data */
UnlockDisplay(dpy);