Make GetFunctionPointerFromNativeLibrary take a const char*
Disappointing as it is to get a bare pointer in there, every
implementation of this function calls an underlying function (usually
dlsym) that needs a NUL-terminated string. base::StringPiece is not
suitable here because a base::StringPiece is not guaranteed to be
NUL-terminated.
We could convert to a std::string first, or take a const std::string&,
which would guarantee NUL-termination, but every caller of this function
passes a string literal, so just use const char*, as that's the closest
thing we have to a type that means "borrowed NUL-terminated string".
Bug: none
Change-Id: I29c1860ef82ded2b19aad62ed6f8212f76bbd71a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4603320
Reviewed-by: danakj <[email protected]>
Auto-Submit: David Benjamin <[email protected]>
Commit-Queue: danakj <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1156897}
diff --git a/base/native_library_fuchsia.cc b/base/native_library_fuchsia.cc
index b0e934e..1379438 100644
--- a/base/native_library_fuchsia.cc
+++ b/base/native_library_fuchsia.cc
@@ -94,8 +94,8 @@
}
void* GetFunctionPointerFromNativeLibrary(NativeLibrary library,
- StringPiece name) {
- return dlsym(library, name.data());
+ const char* name) {
+ return dlsym(library, name);
}
std::string GetNativeLibraryName(StringPiece name) {