From d84b53aa06fbcf529deb413e18c5c4f3e562c6dc Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 24 Aug 2022 10:28:27 +0200 Subject: source: avoid null pointer access in uc_source_runpath_set() When loading a precompiled program from stdin, the input source runpath is unset which subsequently leads to a null pointer being passed to uc_source_runpath_set() when will then attempt to strdup() it, leading to a null pointer access. Properly handle this case and only duplicate non-null pointers. Signed-off-by: Jo-Philipp Wich --- source.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source.c b/source.c index 902ad4c..3bdc210 100644 --- a/source.c +++ b/source.c @@ -194,7 +194,7 @@ uc_source_runpath_set(uc_source_t *source, const char *runpath) if (source->runpath != source->filename) free(source->runpath); - source->runpath = xstrdup(runpath); + source->runpath = runpath ? xstrdup(runpath) : NULL; } bool -- cgit v1.2.3