From 91a9a11b75877a3b36f81ee40e16ef09ce2e5318 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 26 Sep 2011 01:53:25 -0400 Subject: [PATCH] avoid use of vasnprintf in base/error.c commit c94f299fc8e602912a7d68c57404a96b98da4037 uses vasnprintf which was previously removed from the libheimbase directory in order to prevent a dependency on libroken. Replace vasnprintf with snprintf and malloc to avoid the dependency. Change-Id: I029e7e6883406ca7311490a3dab4b65cad3ba70b --- base/error.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/base/error.c b/base/error.c index 4a9871919..91c660be8 100644 --- a/base/error.c +++ b/base/error.c @@ -92,12 +92,17 @@ heim_error_t heim_error_createv(int error_code, const char *fmt, va_list ap) { heim_error_t e; - char *str = NULL; + char *str; int len; - len = vasprintf(&str, fmt, ap); - if (len < 0 || str == NULL) + str = malloc(1024); + if (str == NULL) + return NULL; + len = vsnprintf(str, 1024, fmt, ap); + if (len < 0) { + free(str); return NULL; + } e = _heim_alloc_object(&_heim_error_object, sizeof(struct heim_error)); if (e) {