blob: 66e33c7462bd322d0793c58cb133fd84c5a92a30 [file] [log] [blame]
commit de903b84c49f80a973f48ea47e46e5e47a186b7e
Author: Fletcher Woodruff <fletcherw@chromium.org>
Date: Mon Oct 12 16:22:40 2020 -0600
dll: fix memory leak in load
In the case where we are unable to get a path for loading libs, and
instead just use LIBDIR, we set 'src = strdup(LIBDIR)'. However, we
never update orig_src to point to src before tokenizing the path with
strsep(), so the memory is never freed.
Update load to always set orig_src to src so that we don't leak memory.
diff --git a/backend/dll.c b/backend/dll.c
index d78d409e8..61ba2f846 100644
--- a/backend/dll.c
+++ b/backend/dll.c
@@ -477,9 +477,6 @@ load (struct backend *be)
DBG (1, "load: malloc failed: %s\n", strerror (errno));
return SANE_STATUS_NO_MEM;
}
- if (orig_src)
- free (orig_src);
- orig_src = src;
snprintf (src, src_len, "%s%s%s", path, DIR_SEP, LIBDIR);
}
else
@@ -494,6 +491,7 @@ load (struct backend *be)
}
DBG (3, "load: searching backend `%s' in `%s'\n", be->name, src);
+ orig_src = src;
dir = strsep (&src, DIR_SEP);
while (dir)