From cfd98a7de22cc07d9fd6269e69235bb328be20f0 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 21 Jun 2022 17:58:43 -0700 Subject: [PATCH] Fix off-by-one in source_file_line_basename() --- include/pybind11/cast.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 841d7d986..ffc5ea985 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -68,13 +68,13 @@ inline const char *cpp_version_in_use() { } inline const char *source_file_line_basename(const char *sfl) { - unsigned i_sep = 0; + unsigned i_base = 0; for (unsigned i = 0; sfl[i] != '\0'; i++) { if (sfl[i] == '/' || sfl[i] == '\\') { - i_sep = i; + i_base = i + 1; } } - return sfl + i_sep; + return sfl + i_base; } namespace {