diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-09-23 14:01:48 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-09-23 15:52:21 +0200 |
commit | 93e234c45c62af9d57041de676d888f7695ac0e8 (patch) | |
tree | 1b83b67f96e9d1406636eeedf615ee2748614178 /jvmfwk/plugins/sunmajor/pluginlib | |
parent | e14a6b3f37c0f462afcc9534c8d4a90b430a6d80 (diff) |
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 <sbergman@redhat.com>
Diffstat (limited to 'jvmfwk/plugins/sunmajor/pluginlib')
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 2 |
1 files changed, 1 insertions, 1 deletions
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; |