diff options
author | defanor <defanor@uberspace.net> | 2023-11-11 23:40:53 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2023-11-11 23:40:53 +0300 |
commit | 3e9081921bac3a97f59699ffba34bcc4301ea2c2 (patch) | |
tree | 1eed05cc9bafab03c125a5323d6d923b95f7bc6b /src/rexmpp_openpgp.c | |
parent | cafe83109a65b6bfd5bc0f3fd642e0833f5ebc78 (diff) |
Check realloc(3) return values
Diffstat (limited to 'src/rexmpp_openpgp.c')
-rw-r--r-- | src/rexmpp_openpgp.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/rexmpp_openpgp.c b/src/rexmpp_openpgp.c index 222ae6b..14e2d35 100644 --- a/src/rexmpp_openpgp.c +++ b/src/rexmpp_openpgp.c @@ -619,7 +619,15 @@ void rexmpp_openpgp_add_keys (rexmpp_t *s, *nkeys = *nkeys + 1; if (*nkeys == *allocated) { *allocated = *allocated * 2; - *keys = realloc(*keys, sizeof(gpgme_key_t *) * *allocated); + gpgme_key_t *new_keys = + realloc(*keys, sizeof(gpgme_key_t *) * *allocated); + if (new_keys == NULL) { + rexmpp_log(s, LOG_ERR, + "Failed to reallocate the OpenPGP keys array: %s", + strerror(errno)); + continue; + } + *keys = new_keys; } } else { gpgme_key_unref((*keys)[*nkeys]); |