From 13c57c3f0c5b2a22e0a522af11e8a8b530471e88 Mon Sep 17 00:00:00 2001 From: Peter Stamfest Date: Thu, 4 Sep 2014 20:40:00 +0200 Subject: [PATCH] Fix NULL pointer dereference error introduced during get_path "fixing" --- src/rrd_client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rrd_client.c b/src/rrd_client.c index 5f2366df..e547d6c6 100644 --- a/src/rrd_client.c +++ b/src/rrd_client.c @@ -119,7 +119,12 @@ static const char *get_path (const char *path, char *resolved_path) /* {{{ */ if (ret == NULL) { rrd_set_error("realpath(%s): %s", path, rrd_strerror(errno)); } else { - strcat(buffer, lastslash); + if (lastslash != NULL) { + strcat(buffer, lastslash); + } else { + strcat(buffer, "/"); + strcat(buffer, path); + } if (resolved_path == NULL) { ret = strdup(buffer); } else { -- 2.47.2