summaryrefslogtreecommitdiffstats
path: root/geo-replication/src
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-07-23 18:11:23 +0530
committerVenky Shankar <vshankar@redhat.com>2015-08-05 22:40:22 -0700
commit548ee04668b310d5e0c2d0e866677173940db78d (patch)
tree6e709b5b69942e1b068eb8ffdfde8ba44767ff25 /geo-replication/src
parent611b2545b012d1c5d0700af6bc1a182f7aa2343a (diff)
geo-rep: Fix gsyncd failing to start on slave
This is a regression introduced by 2ca6441. The memory is freed while the caller expects it be not. The patch fixes the same. Change-Id: I76d95eef15b3f7af365b392f2426c8b0388254fc BUG: 1222898 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/11751 Reviewed-by: Saravanakumar Arumugam <sarumuga@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Milind Changire <mchangir@redhat.com> Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'geo-replication/src')
-rw-r--r--geo-replication/src/gsyncd.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/geo-replication/src/gsyncd.c b/geo-replication/src/gsyncd.c
index 018b4429176..c9c863ca2fd 100644
--- a/geo-replication/src/gsyncd.c
+++ b/geo-replication/src/gsyncd.c
@@ -62,14 +62,16 @@ str2argv (char *str, char ***argv)
char *p = NULL;
char *savetok = NULL;
char *temp = NULL;
+ char *temp1 = NULL;
int argc = 0;
size_t argv_len = 32;
int ret = 0;
+ int i = 0;
assert (str);
temp = str = strdup (str);
if (!str)
- return -1;
+ goto error;
*argv = calloc (argv_len, sizeof (**argv));
if (!*argv)
@@ -86,7 +88,10 @@ str2argv (char *str, char ***argv)
if (ret == -1)
goto error;
}
- (*argv)[argc - 1] = p;
+ temp1 = strdup (p);
+ if (!temp1)
+ goto error;
+ (*argv)[argc - 1] = temp1;
}
free(temp);
@@ -95,6 +100,9 @@ str2argv (char *str, char ***argv)
error:
fprintf (stderr, "out of memory\n");
free(temp);
+ for (i = 0; i < argc - 1; i++)
+ free((*argv)[i]);
+ free(*argv);
return -1;
}
@@ -346,6 +354,7 @@ main (int argc, char **argv)
struct invocable *i = NULL;
char *b = NULL;
char *sargv = NULL;
+ int j = 0;
#ifdef USE_LIBGLUSTERFS
glusterfs_ctx_t *ctx = NULL;
@@ -410,6 +419,8 @@ main (int argc, char **argv)
fprintf (stderr, "invoking %s in restricted SSH session is not allowed\n",
b);
+ for (j = 1; j < argc; j++)
+ free(argv[j]);
free(argv);
return 1;
}