From 86406afae416d2361d31a59d9d2ff1fd225f55a0 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Tue, 28 Mar 2006 18:59:01 +0000
Subject: [PATCH] Fix error handling on malloc failure.

---
 src/common/hostlist.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/common/hostlist.c b/src/common/hostlist.c
index 8945bcef3da..45af4d681f4 100644
--- a/src/common/hostlist.c
+++ b/src/common/hostlist.c
@@ -1129,8 +1129,10 @@ static int hostlist_push_range(hostlist_t hl, hostrange_t hr)
 	&& hostrange_width_combine(tail, hr)) {
 		tail->hi = hr->hi;
 	} else {
-		if ((hl->hr[hl->nranges++] = hostrange_copy(hr)) == NULL)
+		hostrange_t new = hostrange_copy(hr);
+		if (new == NULL)
 			goto error;
+		hl->hr[hl->nranges++] = new;
 	}
 
 	retval = hl->nhosts += hostrange_count(hr);
-- 
GitLab