From 65f1b15c953805816133db3d3f92ff4c35c57741 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 7 Mar 2024 03:35:47 +0100 Subject: [PATCH] Merge pull request #9934 from nmeum/absPath-out-of-bounds absPath: Explicitly check if path is empty before accessing it (cherry picked from commit 6ec08b85f607852eb6f976c1392c4917d0a53787) Change-Id: Ieeb53fb65d0e334e6017ceb3a48b3b6ae1047843 --- src/libutil/util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 6fcce5d67..51cda9da4 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -115,7 +115,7 @@ void replaceEnv(const std::map & newEnv) Path absPath(Path path, std::optional dir, bool resolveSymlinks) { - if (path[0] != '/') { + if (path.empty() || path[0] != '/') { if (!dir) { #ifdef __GNU__ /* GNU (aka. GNU/Hurd) doesn't have any limitation on path