mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
gpg: Fix format_keyid.
* g10/keyid.c (format_keyid): Allocate buffer earlier. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org> (cherry picked from commit a9be9f4e6e6d451698afa3d4780a53ed3718b30b)
This commit is contained in:
parent
7d8564cf88
commit
dccc471de4
@ -326,11 +326,12 @@ keyid_copy (u32 *dest, const u32 *src)
|
|||||||
char *
|
char *
|
||||||
format_keyid (u32 *keyid, int format, char *buffer, int len)
|
format_keyid (u32 *keyid, int format, char *buffer, int len)
|
||||||
{
|
{
|
||||||
char tmp[KEYID_STR_SIZE];
|
|
||||||
if (! buffer)
|
if (! buffer)
|
||||||
{
|
{
|
||||||
buffer = tmp;
|
len = KEYID_STR_SIZE;
|
||||||
len = sizeof (tmp);
|
buffer = xtrymalloc (len);
|
||||||
|
if (!buffer)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format == KF_DEFAULT)
|
if (format == KF_DEFAULT)
|
||||||
@ -365,8 +366,6 @@ format_keyid (u32 *keyid, int format, char *buffer, int len)
|
|||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer == tmp)
|
|
||||||
return xstrdup (buffer);
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user