From 7f60ebff2741f2917aef038ae8d27d88680b4e2f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 29 May 2020 15:39:40 +0200 Subject: [PATCH] logger: handle file without '/' in it --- spa/plugins/support/logger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index 7d100ce34..45c9087fc 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -74,7 +74,7 @@ impl_log_logv(void *object, va_list args) { struct impl *impl = object; - char location[1024], *p; + char location[1024], *p, *s; static const char *levels[] = { "-", "E", "W", "I", "D", "T", "*T*" }; const char *prefix = "", *suffix = ""; int size, len; @@ -107,8 +107,9 @@ impl_log_logv(void *object, } if (impl->line && line != 0) { + s = strrchr(file, '/'); size += snprintf(p + size, len - size, "[%s:%i %s()]", - strrchr(file, '/') + 1, line, func); + s ? s + 1 : file, line, func); } size += snprintf(p + size, len - size, " "); size += vsnprintf(p + size, len - size, fmt, args);