commit 062994697d10f0fe26525885aa80228b69ef46ff
parent a1516864b3bb37b610c53516f17a609d64ae4c7e
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 3 Sep 2012 13:40:54 +0000
fix use after free
Diffstat:
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/main/extractor_plugpath.c b/src/main/extractor_plugpath.c
@@ -305,7 +305,7 @@ get_path_from_PATH() {
LOG_STRERROR ("strdup");
return NULL;
}
- if (NULL == (buf = malloc (strlen(path) + 20)))
+ if (NULL == (buf = malloc (strlen (path) + 20)))
{
LOG_STRERROR ("malloc");
free (path);
@@ -315,18 +315,19 @@ get_path_from_PATH() {
while (NULL != (end = strchr(pos, ':')))
{
*end = '\0';
- sprintf(buf, "%s/%s", pos, "extract");
+ sprintf (buf, "%s/%s", pos, "extract");
if (0 == stat(buf, &sbuf))
{
free (buf);
- free (path);
- if (NULL == (pos = strdup(pos)))
+ if (NULL == (pos = strdup (pos)))
{
LOG_STRERROR ("strdup");
+ free (path);
return NULL;
}
+ free (path);
pos = cut_bin (pos);
- if (NULL == (ret = realloc (pos, strlen(pos) + 5)))
+ if (NULL == (ret = realloc (pos, strlen (pos) + 5)))
{
LOG_STRERROR ("realloc");
free (pos);
@@ -337,7 +338,7 @@ get_path_from_PATH() {
}
pos = end + 1;
}
- sprintf(buf, "%s/%s", pos, "extract");
+ sprintf (buf, "%s/%s", pos, "extract");
if (0 == stat (buf, &sbuf))
{
pos = strdup (pos);
@@ -346,7 +347,7 @@ get_path_from_PATH() {
if (NULL == pos)
return NULL;
pos = cut_bin (pos);
- if (NULL == (ret = realloc (pos, strlen(pos) + 5)))
+ if (NULL == (ret = realloc (pos, strlen (pos) + 5)))
{
LOG_STRERROR ("realloc");
free (pos);
@@ -355,8 +356,8 @@ get_path_from_PATH() {
strcat (ret, "lib/");
return ret;
}
- free(buf);
- free(path);
+ free (buf);
+ free (path);
return NULL;
}