mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01:00
gpg: Remove some xmallocs.
* g10/getkey.c (get_pubkeys): Do not use xmalloc. -- We eventually need to get rid of all xmallocs so that gpg won't fail easily when we make more use of the s server mode. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
8602b980df
commit
29119a6492
33
g10/getkey.c
33
g10/getkey.c
@ -497,7 +497,7 @@ get_pubkeys (ctrl_t ctrl,
|
|||||||
search_terms, gpg_strerror (err));
|
search_terms, gpg_strerror (err));
|
||||||
if (!opt.quiet && source)
|
if (!opt.quiet && source)
|
||||||
log_info (_("(check argument of option '%s')\n"), source);
|
log_info (_("(check argument of option '%s')\n"), source);
|
||||||
goto out;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warn_possibly_ambiguous
|
if (warn_possibly_ambiguous
|
||||||
@ -517,8 +517,16 @@ get_pubkeys (ctrl_t ctrl,
|
|||||||
count = 0;
|
count = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
PKT_public_key *pk = xmalloc_clear (sizeof *pk);
|
PKT_public_key *pk;
|
||||||
KBNODE kb;
|
KBNODE kb;
|
||||||
|
|
||||||
|
pk = xtrycalloc (1, sizeof *pk);
|
||||||
|
if (!pk)
|
||||||
|
{
|
||||||
|
err = gpg_error_from_syserror ();
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
pk->req_usage = use;
|
pk->req_usage = use;
|
||||||
|
|
||||||
if (! ctx)
|
if (! ctx)
|
||||||
@ -542,7 +550,13 @@ get_pubkeys (ctrl_t ctrl,
|
|||||||
/* Another result! */
|
/* Another result! */
|
||||||
count ++;
|
count ++;
|
||||||
|
|
||||||
r = xmalloc_clear (sizeof (*r));
|
r = xtrycalloc (1, sizeof (*r));
|
||||||
|
if (!r)
|
||||||
|
{
|
||||||
|
err = gpg_error_from_syserror ();
|
||||||
|
xfree (pk);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
r->pk = pk;
|
r->pk = pk;
|
||||||
r->keyblock = kb;
|
r->keyblock = kb;
|
||||||
r->next = results;
|
r->next = results;
|
||||||
@ -569,14 +583,14 @@ get_pubkeys (ctrl_t ctrl,
|
|||||||
if (!opt.quiet && source)
|
if (!opt.quiet && source)
|
||||||
log_info (_("(check argument of option '%s')\n"), source);
|
log_info (_("(check argument of option '%s')\n"), source);
|
||||||
|
|
||||||
goto out;
|
goto leave;
|
||||||
}
|
}
|
||||||
else if (gpg_err_code (err) == GPG_ERR_NOT_FOUND)
|
else if (gpg_err_code (err) == GPG_ERR_NOT_FOUND)
|
||||||
; /* No more matches. */
|
; /* No more matches. */
|
||||||
else if (err)
|
else if (err)
|
||||||
{ /* Some other error. An error message was already printed out.
|
{ /* Some other error. An error message was already printed out.
|
||||||
* Free RESULTS and continue. */
|
* Free RESULTS and continue. */
|
||||||
goto out;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for duplicates. */
|
/* Check for duplicates. */
|
||||||
@ -641,7 +655,7 @@ get_pubkeys (ctrl_t ctrl,
|
|||||||
fingerprint, sizeof fingerprint));
|
fingerprint, sizeof fingerprint));
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
leave:
|
||||||
if (err)
|
if (err)
|
||||||
pubkeys_free (results);
|
pubkeys_free (results);
|
||||||
else
|
else
|
||||||
@ -712,8 +726,13 @@ get_pubkey (ctrl_t ctrl, PKT_public_key * pk, u32 * keyid)
|
|||||||
/* More init stuff. */
|
/* More init stuff. */
|
||||||
if (!pk)
|
if (!pk)
|
||||||
{
|
{
|
||||||
pk = xmalloc_clear (sizeof *pk);
|
|
||||||
internal++;
|
internal++;
|
||||||
|
pk = xtrycalloc (1, sizeof *pk);
|
||||||
|
if (!pk)
|
||||||
|
{
|
||||||
|
rc = gpg_error_from_syserror ();
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user