diff options
author | Jim Meyering <meyering@redhat.com> | 2012-08-08 17:11:52 +0200 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-08-08 23:01:43 -0700 |
commit | 94271805633a1ee5487b036dfd81b63c0250df39 (patch) | |
tree | b7f679a4961b07c95dd0738af2483a0b2432a455 /xlators/mgmt | |
parent | bfac66f129646bc78f1ed3a7dccb3010114e57aa (diff) |
geo-rep: don't leak or segfault upon OOM
In glusterd_urltransform, a failed GF_REALLOC would clobber
the would-be-realloc'd buffer, linearr, with a NULL pointer,
(thus leaking that memory) and then control would pass to the
error-handling code that would attempt to free
(via glusterd_urltransform_free) linearr[i], which is almost
guaranteed to segfault when linearr is NULL.
Change-Id: Ia75bf70fd8ff893a18804d49688048ef96db6037
BUG: 846755
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3791
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index 901e5e1e6c2..db0ab9cc83a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -249,13 +249,15 @@ glusterd_urltransform (runner_t *runner, char ***linearrp) line[len - 1] = '\0'; if (arr_idx == arr_len) { + void *p = linearr; arr_len <<= 1; - linearr = GF_REALLOC (linearr, arr_len); - if (!linearr) { + p = GF_REALLOC (linearr, arr_len); + if (!p) { GF_FREE (line); error = _gf_true; goto out; } + linearr = p; } linearr[arr_idx] = line; |