mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2026-05-14 05:58:08 +02:00
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)
This commit is contained in:
parent
a4ef3552eb
commit
30437b47c8
1 changed files with 1 additions and 1 deletions
2
pkg.c
2
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue