From 58b0957c48506083addde7a302ce82225002eb2f Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Tue, 6 Jan 2015 23:40:24 +0100 Subject: erec: use stdio vasprintf instead of gmp_vasprintf Use stdio's vasprintf instead of gmp_vasprintf which is not part of the mini-gmp function subset. Furthermore convert the only gmp-specific user and allow the compiler to verify format-strings. Signed-off-by: Steven Barth Signed-off-by: Pablo Neira Ayuso --- src/erec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/erec.c') diff --git a/src/erec.c b/src/erec.c index 82543e6d..810e9bfd 100644 --- a/src/erec.c +++ b/src/erec.c @@ -44,6 +44,7 @@ static void erec_destroy(struct error_record *erec) xfree(erec); } +__attribute__((format(printf, 3, 0))) struct error_record *erec_vcreate(enum error_record_types type, const struct location *loc, const char *fmt, va_list ap) @@ -55,10 +56,13 @@ struct error_record *erec_vcreate(enum error_record_types type, erec->num_locations = 0; erec_add_location(erec, loc); - gmp_vasprintf(&erec->msg, fmt, ap); + if (vasprintf(&erec->msg, fmt, ap) < 0) + erec->msg = NULL; + return erec; } +__attribute__((format(printf, 3, 4))) struct error_record *erec_create(enum error_record_types type, const struct location *loc, const char *fmt, ...) -- cgit v1.2.3