summaryrefslogtreecommitdiffstats
path: root/geo-replication
diff options
context:
space:
mode:
authorSheetal Pamecha <spamecha@redhat.com>2019-05-31 17:21:22 +0530
committerAmar Tumballi <amarts@redhat.com>2019-06-17 03:39:21 +0000
commit1cb32e3df2775dabc57df6931ffce96aece7109e (patch)
tree137449792b6237da2a00eb1736a049921ab70df8 /geo-replication
parent82b8458ac6d31c72dc7a2f69df7f50bb1e4b7618 (diff)
geo-rep/gsyncd: name is not freed in one of the cases
CID: 1400730 updates: bz#789278 Change-Id: I0f6924050a31d3d2cc0b555f859920e349728e0a Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
Diffstat (limited to 'geo-replication')
-rw-r--r--geo-replication/src/procdiggy.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/geo-replication/src/procdiggy.c b/geo-replication/src/procdiggy.c
index 6f6ee64bb3a..8068ef79a42 100644
--- a/geo-replication/src/procdiggy.c
+++ b/geo-replication/src/procdiggy.c
@@ -31,6 +31,10 @@ pidinfo(pid_t pid, char **name)
};
char *p = NULL;
int ret = 0;
+ pid_t lpid = -1;
+
+ if (name)
+ *name = NULL;
snprintf(path, sizeof path, PROC "/%d/status", pid);
@@ -38,14 +42,12 @@ pidinfo(pid_t pid, char **name)
if (!f)
return -1;
- if (name)
- *name = NULL;
for (;;) {
size_t len;
memset(buf, 0, sizeof(buf));
if (fgets(buf, sizeof(buf), f) == NULL || (len = strlen(buf)) == 0 ||
buf[len - 1] != '\n') {
- pid = -1;
+ lpid = -1;
goto out;
}
buf[len - 1] = '\0';
@@ -57,7 +59,7 @@ pidinfo(pid_t pid, char **name)
;
*name = gf_strdup(p);
if (!*name) {
- pid = -2;
+ lpid = -2;
goto out;
}
continue;
@@ -71,17 +73,17 @@ pidinfo(pid_t pid, char **name)
while (isspace(*++p))
;
- ret = gf_string2int(p, &pid);
+ ret = gf_string2int(p, &lpid);
if (ret == -1)
- pid = -1;
+ lpid = -1;
out:
fclose(f);
- if (pid == -1 && name && *name)
+ if (lpid == -1 && name && *name)
GF_FREE(*name);
- if (pid == -2)
+ if (lpid == -2)
fprintf(stderr, "out of memory\n");
- return pid;
+ return lpid;
}
int