diff options
author | Daniel Macks <dmacks@netspace.org> | 2014-11-12 07:47:57 -0800 |
---|---|---|
committer | Dan Nicholson <dbn.lists@gmail.com> | 2014-11-12 07:47:57 -0800 |
commit | 30437b47c81590bf8b9efffd19f9a42e6112b9cb (patch) | |
tree | 40804b29b148e417e80828d1d76f05aa260a5553 | |
parent | a4ef3552eb6877243cdc5b16cbbc2201047c7973 (diff) | |
download | pkg-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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); |