From 0c1244a2b7e30ab0610ae70166e1b5d0219782c3 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 4 Dec 2017 12:08:31 +0100 Subject: core: Also check for a failed selftest in gpgm_data_new. * src/data.c (_gpgme_data_new): Check for failed selftest. * tests/run-support.h (make_filename): Print a message on mallooc failure. (init_gpgme_basic): New. * tests/run-identify.c (main): Call init_gpgme_basic becuase we do not need to setup a protocol. * tests/t-data.c: Define PGM and include run-support.h. (make_filename): Remove. (main): Call init_gpgme_basic. -- Note: This patch may break applications which used gpgme_data but no gpgme_new without having called the required gpgme_check_version. GPGME can be used without a protocol for example to work with the data object abstraction. Thus a call to gpgme_data_new also needs to check the result of the core selftests - including on whether gpgme_check_version has been called. Signed-off-by: Werner Koch --- src/data.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/data.c b/src/data.c index e4e9ee3f..7ae5b327 100644 --- a/src/data.c +++ b/src/data.c @@ -46,6 +46,10 @@ _gpgme_data_new (gpgme_data_t *r_dh, struct _gpgme_data_cbs *cbs) return gpg_error (GPG_ERR_INV_VALUE); *r_dh = NULL; + + if (_gpgme_selftest) + return _gpgme_selftest; + dh = calloc (1, sizeof (*dh)); if (!dh) return gpg_error_from_syserror (); -- cgit v1.2.3