summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2016-05-02 19:06:47 +0530
committerNiels de Vos <ndevos@redhat.com>2016-09-07 07:04:56 -0700
commita3f6b608f5c34ca4ded05c3b7dc272d8df68345a (patch)
treea2d4716e6d5265b4ed592fdde8d41ab813a6cca3
parent020787a93f997f4fd2e16818e73d030b3ef4e4e8 (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() >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> Change-Id: I179fb1c095cf4d331b5910df6388dc724cb4ac96 BUG: 1332424 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> Change-Id: Id60c851c5462868630349dd4707fd94f1b83e488 Reviewed-on: http://review.gluster.org/15377 Tested-by: Atin Mukherjee <amukherj@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prasanna Kumar Kalever <pkalever@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
-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);