From 4720a07b1c626f025bf9a3e20c861ffdd9cbc11a Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Sun, 24 Nov 2024 20:59:07 -0800 Subject: [PATCH] switch back to len(min of parts); avoids OOB array access --- python/private/py_executable_bazel.bzl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/private/py_executable_bazel.bzl b/python/private/py_executable_bazel.bzl index 8db867e64e..3778c192b4 100644 --- a/python/private/py_executable_bazel.bzl +++ b/python/private/py_executable_bazel.bzl @@ -360,7 +360,8 @@ def relative_path(from_, to): to_parts = to.split("/") # Strip common leading parts from both paths - for _ in range(len(to)): + n = min(len(from_parts), len(to_parts)) + for _ in range(n): if from_parts[0] == to_parts[0]: from_parts.pop(0) to_parts.pop(0)