log BUGFIX avoid misinterpretation of %
diff --git a/src/log.c b/src/log.c
index b842cbd..97c7b28 100644
--- a/src/log.c
+++ b/src/log.c
@@ -626,11 +626,10 @@
}
/**
- * @brief Exact same functionality as ::ly_err_print() but has variable arguments so va_start() can
- * be used and an empty va_list created.
+ * @brief Exact same functionality as ::ly_err_print() but has variable arguments so log_vprintf() can be called.
*/
static void
-_ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem, ...)
+_ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem, const char *format, ...)
{
va_list ap;
char *path_dup = NULL;
@@ -643,17 +642,14 @@
LY_CHECK_ERR_RET(!path_dup, LOGMEM(ctx), );
}
- va_start(ap, eitem);
- log_vprintf(ctx, eitem->level, eitem->no, eitem->vecode, eitem->path, eitem->msg, ap);
+ va_start(ap, format);
+ log_vprintf(ctx, eitem->level, eitem->no, eitem->vecode, path_dup, format, ap);
va_end(ap);
-
- if (path_dup) {
- eitem->path = path_dup;
- }
}
API void
ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem)
{
- _ly_err_print(ctx, eitem);
+ /* String ::ly_err_item.msg cannot be used directly because it may contain the % character */
+ _ly_err_print(ctx, eitem, "%s", eitem->msg);
}