public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - dlm_controld: handle heap allocation failure and plug leaks
@ 2009-06-26 8:51 Jim Meyering
0 siblings, 0 replies; only message in thread
From: Jim Meyering @ 2009-06-26 8:51 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a5adf14a27e9cadc0b355af01fc416528a942372
Commit: a5adf14a27e9cadc0b355af01fc416528a942372
Parent: d1cf79fca3cdd98fc11e03635791b4688ff69782
Author: Jim Meyering <meyering@redhat.com>
AuthorDate: Mon Jun 22 23:37:21 2009 +0200
Committer: Jim Meyering <meyering@redhat.com>
CommitterDate: Fri Jun 26 10:49:47 2009 +0200
dlm_controld: handle heap allocation failure and plug leaks
* group/dlm_controld/pacemaker.c (process_cluster): Don't dereference
NULL upon failing malloc or realloc. Free "header" upon failure.
---
group/dlm_controld/pacemaker.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/group/dlm_controld/pacemaker.c b/group/dlm_controld/pacemaker.c
index fed9ca7..5825adc 100644
--- a/group/dlm_controld/pacemaker.c
+++ b/group/dlm_controld/pacemaker.c
@@ -136,9 +136,11 @@ void process_cluster(int ci)
AIS_Message *msg = NULL;
SaAisErrorT rc = SA_AIS_OK;
mar_res_header_t *header = NULL;
+ mar_res_header_t *h_new;
static int header_len = sizeof(mar_res_header_t);
- header = malloc(header_len);
+ if ((header = malloc(header_len)) == NULL)
+ goto bail;
memset(header, 0, header_len);
errno = 0;
@@ -160,8 +162,12 @@ void process_cluster(int ci)
} else if(header->error != 0) {
log_error("Header contined error: %d", header->error);
}
-
- header = realloc(header, header->size);
+
+ h_new = realloc(header, header->size);
+ if (h_new == NULL)
+ goto bail;
+ header = h_new;
+
/* Use a char* so we can store the remainder into an offset */
data = (char*)header;
@@ -250,6 +256,7 @@ void process_cluster(int ci)
goto done;
bail:
+ free (header);
log_error("AIS connection failed");
return;
}
@@ -406,4 +413,3 @@ int fence_in_progress(int *count)
{
return 0;
}
-
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-06-26 8:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-26 8:51 cluster: STABLE3 - dlm_controld: handle heap allocation failure and plug leaks Jim Meyering
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).