summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2016-05-02 19:06:47 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2016-07-19 04:25:35 -0700
commit7bf882ed1757f8b01d18d35ef869ed2cd49f1b2f (patch)
treeb37e39b45fca9d6308800daa303437da862d7e36
parent1b228d3d489cada1c3c9f5fdbb882e7dbc25a091 (diff)
geo-rep: address potential leak of memory
fix memory leak reported by clang analyzer: gsyncd.c:411:17: warning: Potential leak of memory pointed to by 'argv' in main() Change-Id: I179fb1c095cf4d331b5910df6388dc724cb4ac96 BUG: 1332419 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> Reviewed-on: http://review.gluster.org/14151 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Kotresh HR <khiremat@redhat.com>
-rw-r--r--geo-replication/src/gsyncd.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/geo-replication/src/gsyncd.c b/geo-replication/src/gsyncd.c
index 1beeda1380c..2c48ca5d540 100644
--- a/geo-replication/src/gsyncd.c
+++ b/geo-replication/src/gsyncd.c
@@ -407,11 +407,18 @@ main (int argc, char **argv)
return invoke_gsyncd (argc, argv);
argc = str2argv (sargv, &argv);
- if (argc == -1 || setenv (_GSYNCD_DISPATCHED_, "1", 1) == -1) {
+
+ if (argc == -1) {
fprintf (stderr, "internal error\n");
return 1;
}
+ if (setenv (_GSYNCD_DISPATCHED_, "1", 1) == -1) {
+ fprintf (stderr, "internal error\n");
+ goto out;
+ }
+
+
b = basename (argv[0]);
for (i = invocables; i->name; i++) {
if (strcmp (b, i->name) == 0)
@@ -421,6 +428,7 @@ main (int argc, char **argv)
fprintf (stderr, "invoking %s in restricted SSH session is not allowed\n",
b);
+out:
for (j = 1; j < argc; j++)
free(argv[j]);
free(argv);