From 93e234c45c62af9d57041de676d888f7695ac0e8 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 23 Sep 2022 14:01:48 +0200 Subject: Fix a misuse of two-argument std string_view rfind ...introduced in 655b6c2f46a73d9893ba8e6b572731a5890a4f72 "loplugin:stringviewparam". Unlike its O[U]String lastIndexOf(x, n) counterpart (which looks for the last x whose end position, exclusive, is <= n), string_view rfind(x, n) looks for the last x whose start position, inclusive, is <= n. (So here would have left slash unchanged.) (And the seemingly simpler jvm_dll.rfind('\\', slash - 1) would fail when slash is zero, as in that case it would call rfind with a second argument of npos, i.e., search for the last '\\' in the complete jvm_dll.) Change-Id: I148a5db860d4b9e9d58a4a8847880a7a7020c5a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140486 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'jvmfwk/plugins/sunmajor/pluginlib') diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 45feea3b1db1..77ea93d69592 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -486,7 +486,7 @@ static void load_msvcr(std::u16string_view jvm_dll, std::u16string_view msvcr) // Then check if msvcr71.dll is in the parent folder of where // jvm.dll is. That is currently (1.6.0_22) as far as I know the // normal case. - slash = jvm_dll.rfind('\\', slash); + slash = jvm_dll.substr(0, slash).rfind('\\'); if (slash == std::u16string_view::npos) return; -- cgit