From e2ded11868b5dc07a3f8f1aab1e6976fb22c6bee Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 31 Aug 2022 18:20:00 +0300 Subject: tree: handle a pointer returned by malloc() It is wrong to assume that malloc() always returns allocated memory. Unfortunately, it can return NULL. The rest of the code that uses malloc() should be refactored. That's the reason why we can't do it right now. --- src/r-gpgme.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/r-gpgme.c') diff --git a/src/r-gpgme.c b/src/r-gpgme.c index cfa2f98..4641e60 100644 --- a/src/r-gpgme.c +++ b/src/r-gpgme.c @@ -175,6 +175,10 @@ char *decrypt_data(const char *path) } data = malloc(sizeof(char) * (maxlen_pass + 1)); + if (!data) { + print_error("Unable to allocate space for the decrypted data.\n"); + goto out_release_plain; + } gpgme_data_read(plain, data, maxlen_pass); out_release_plain: -- cgit v1.2.3-18-g5258