From 51fd6d8292cb41d743407e6ac9d86a5ab8e68d8c Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 6 Feb 2013 17:35:40 +0100 Subject: Use gpg_error_from_syserror instead of directly accessing errno. -- Also fixed a couple of minor thing; e.g. save the error before calling cleanup functions. Do not save the errno if only free is called in between. --- src/data-mem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/data-mem.c') diff --git a/src/data-mem.c b/src/data-mem.c index 634f8a53..fc7694d2 100644 --- a/src/data-mem.c +++ b/src/data-mem.c @@ -202,9 +202,9 @@ gpgme_data_new_from_mem (gpgme_data_t *r_dh, const char *buffer, char *bufcpy = malloc (size); if (!bufcpy) { - int saved_errno = errno; + int saved_err = gpg_error_from_syserror (); _gpgme_data_release (*r_dh); - return TRACE_ERR (gpg_error_from_errno (saved_errno)); + return TRACE_ERR (saved_err); } memcpy (bufcpy, buffer, size); (*r_dh)->data.mem.buffer = bufcpy; @@ -242,9 +242,9 @@ gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len) str = malloc (dh->data.mem.length); if (!str) { - int saved_errno = errno; + int saved_err = gpg_error_from_syserror (); gpgme_data_release (dh); - TRACE_ERR (gpg_error_from_errno (saved_errno)); + TRACE_ERR (saved_err); return NULL; } memcpy (str, dh->data.mem.orig_buffer, dh->data.mem.length); -- cgit v1.2.3