summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Macks <dmacks@netspace.org>2014-11-12 07:47:57 -0800
committerDan Nicholson <dbn.lists@gmail.com>2014-11-12 07:47:57 -0800
commit30437b47c81590bf8b9efffd19f9a42e6112b9cb (patch)
tree40804b29b148e417e80828d1d76f05aa260a5553
parenta4ef3552eb6877243cdc5b16cbbc2201047c7973 (diff)
downloadpkg-config-30437b47c81590bf8b9efffd19f9a42e6112b9cb.tar.gz
Use same token for malloc as for string construction
The goal is for pkgname to hold the name without the trailing ".pc" extension (according to the meaning of EXT_LEN as used in the ends_in_dotpc() function). But the malloc is hardcoded as 2. If the extension were to be changed, the number of characters being strncpy'ed would not match the size of the target buffer. Instead, the malloc should use the EXT_LEN token (adjusted for the trailing \0). Freedesktop #80378 (https://bugs.freedesktop.org/show_bug.cgi?id=80378)
-rw-r--r--pkg.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkg.c b/pkg.c
index 2d13a52..825c38a 100644
--- a/pkg.c
+++ b/pkg.c
@@ -178,7 +178,7 @@ scan_dir (char *dirname)
if (ends_in_dotpc (dent->d_name))
{
- char *pkgname = g_malloc (len - 2);
+ char *pkgname = g_malloc (len - EXT_LEN + 1);
debug_spew ("File '%s' appears to be a .pc file\n", dent->d_name);