summaryrefslogtreecommitdiff
path: root/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'expr.c')
-rw-r--r--expr.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/expr.c b/expr.c
index 8351f2c..4af45c3 100644
--- a/expr.c
+++ b/expr.c
@@ -762,13 +762,20 @@ ExprResolveString(ExprDef * expr,
if (ExprResolveString(left, &leftRtrn, lookup, lookupPriv) &&
ExprResolveString(right, &rightRtrn, lookup, lookupPriv))
{
- int len;
char *new;
- len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
+
+#ifdef HAVE_ASPRINTF
+ if (asprintf(&new, "%s%s", leftRtrn.str, rightRtrn.str) < 0)
+ new = NULL;
+#else
+ size_t len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
new = malloc(len);
+#endif
if (new)
{
+#ifndef HAVE_ASPRINTF
snprintf(new, len, "%s%s", leftRtrn.str, rightRtrn.str);
+#endif
val_rtrn->str = new;
return True;
}