From 1c454aee81e38ffbc4a615092742ae4b1e37b57f Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 22 Jun 2009 14:50:17 +0000 Subject: 2009-06-22 Marcus Brinkmann * configure.ac: Add AC_TYPE_UINTPTR_T. * assuan/assuan.h [_ASSUAN_IN_GPGME_BUILD_ASSUAN]: Declare _gpgme_io_connect. src/ 2009-06-22 Marcus Brinkmann * debug.h: Everywhere, use %p instead of 0x%x to print pointer. [HAVE_STDINT_H]: Include . (_TRACE, TRACE, TRACE0, TRACE1, TRACE2, TRACE3, TRACE6): Cast tag to (uintptr_t) before casting it to (void*) to silence GCC warning. * gpgme.h.in (_GPGME_DEPRECATED_OUTSIDE_GPGME): New macro. * sign.c (_GPGME_IN_GPGME): Define it. * keylist.c (_GPGME_IN_GPGME): Define it. * debug.c (_gpgme_debug_begin, _gpgme_debug_add): Handle error in vasprintf and asprintf. * priv-io.h: Include . Declare _gpgme_io_connect. tests/ 2009-06-22 Marcus Brinkmann * gpg/t-support.h (passphrase_cb): Implement write() according to the book to silence compiler warning. * gpgsm/t-support.h (passphrase_cb): Likewise. --- src/debug.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/debug.c') diff --git a/src/debug.c b/src/debug.c index d529653a..979c6256 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1,6 +1,6 @@ /* debug.c - helpful output in desperate situations Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 g10 Code GmbH This file is part of GPGME. @@ -197,6 +197,7 @@ void _gpgme_debug_begin (void **line, int level, const char *format, ...) { va_list arg_ptr; + int res; debug_init (); if (debug_level < level) @@ -207,8 +208,10 @@ _gpgme_debug_begin (void **line, int level, const char *format, ...) } va_start (arg_ptr, format); - vasprintf ((char **) line, format, arg_ptr); + res = vasprintf ((char **) line, format, arg_ptr); va_end (arg_ptr); + if (res < 0) + *line = NULL; } @@ -219,17 +222,26 @@ _gpgme_debug_add (void **line, const char *format, ...) va_list arg_ptr; char *toadd; char *result; + int res; if (!*line) return; va_start (arg_ptr, format); - vasprintf (&toadd, format, arg_ptr); + res = vasprintf (&toadd, format, arg_ptr); va_end (arg_ptr); - asprintf (&result, "%s%s", *(char **) line, toadd); - free (*line); + if (res < 0) + { + free (*line); + *line = NULL; + } + res = asprintf (&result, "%s%s", *(char **) line, toadd); free (toadd); - *line = result; + free (*line); + if (res < 0) + *line = NULL; + else + *line = result; } -- cgit v1.2.3