[compiler-rt] Fix possible underflow in ParseAndSetPath (PR #159389)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 18 08:10:43 PDT 2025


https://github.com/gbMattN updated https://github.com/llvm/llvm-project/pull/159389

>From 6a4853f57bce81ddedab1283a660ea8a1a7bf18c Mon Sep 17 00:00:00 2001
From: Nagy <Matthew.Nagy at sony.com>
Date: Wed, 17 Sep 2025 16:51:59 +0100
Subject: [PATCH] Fix possible underflow in ParseAndSetPath

---
 compiler-rt/lib/sanitizer_common/sanitizer_file.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
index 9236a458cdb0e..a2c0a9c39d04e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
@@ -108,6 +108,9 @@ static void ParseAndSetPath(const char *pattern, char *dest,
   CHECK(dest);
   CHECK_GE(dest_size, 1);
   dest[0] = '\0';
+  // Return empty string if empty string was passed
+  if (internal_strlen(pattern) == 0)
+    return;
   uptr next_substr_start_idx = 0;
   for (uptr i = 0; i < internal_strlen(pattern) - 1; i++) {
     if (pattern[i] != '%')



More information about the llvm-commits mailing list