aboutsummaryrefslogtreecommitdiffstats
path: root/src/r-gpgme.c
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-08-31 18:20:00 +0300
committerJoursoir <chat@joursoir.net>2022-08-31 19:14:03 +0300
commite2ded11868b5dc07a3f8f1aab1e6976fb22c6bee (patch)
tree1263874d5debf94294b75ba365f1aa6068e239d6 /src/r-gpgme.c
parent471a67cd6bb133267e9e26ee0c4a6a934299253f (diff)
downloadlock-password-e2ded11868b5dc07a3f8f1aab1e6976fb22c6bee.tar.gz
lock-password-e2ded11868b5dc07a3f8f1aab1e6976fb22c6bee.tar.bz2
lock-password-e2ded11868b5dc07a3f8f1aab1e6976fb22c6bee.zip
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.
Diffstat (limited to 'src/r-gpgme.c')
-rw-r--r--src/r-gpgme.c4
1 files changed, 4 insertions, 0 deletions
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: