Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
examples/simplelog.c | 6 ++++++
lib/log_format.c | 6 +++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/examples/simplelog.c b/examples/simplelog.c
index 8fb0941..17e3b61 100644
--- a/examples/simplelog.c
+++ b/examples/simplelog.c
@@ -226,6 +226,12 @@ main(int32_t argc, char *argv[])
qb_log(LOG_DEBUG, "hello");
qb_log(LOG_INFO, "this is an info");
qb_log(LOG_NOTICE, "hello - notice?");
+ {
+ char * str = NULL;
+ qb_log(LOG_ERR,
+ "%s ------%s------------- %u?",
+ NULL, str, 56);
+ }
func_one();
func_two();
diff --git a/lib/log_format.c b/lib/log_format.c
index 0cbb543..6a74fbb 100644
--- a/lib/log_format.c
+++ b/lib/log_format.c
@@ -494,7 +494,11 @@ reprocess:
{
char *arg_string;
arg_string = va_arg(ap, char *);
- p = stpcpy(&serialize[location], arg_string);
+ if (arg_string == NULL) {
+ p = stpcpy(&serialize[location], "(null)");
+ } else {
+ p = stpcpy(&serialize[location], arg_string);
+ }
location += p - &serialize[location] + 1;
break;
}
--
1.7.10.1
Show replies by date