[Lldb-commits] [lldb] 290e43d - [lldb] Use llvm::format in AppleObjCRuntimeV2.cpp
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 26 06:02:41 PST 2019
Author: Pavel Labath
Date: 2019-11-26T15:04:13+01:00
New Revision: 290e43ddb660db2e9b294e1e963222c08965d211
URL: https://github.com/llvm/llvm-project/commit/290e43ddb660db2e9b294e1e963222c08965d211
DIFF: https://github.com/llvm/llvm-project/commit/290e43ddb660db2e9b294e1e963222c08965d211.diff
LOG: [lldb] Use llvm::format in AppleObjCRuntimeV2.cpp
Crushing a "sprintf" buffer is null warning.
Added:
Modified:
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 9bdbef393e39..750b6ce6b0c6 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1625,19 +1625,13 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
// Substitute in the correct class_getName / class_getNameRaw function name,
// concatenate the two parts of our expression text. The format string
// has two %s's, so provide the name twice.
- int prefix_string_size = snprintf (nullptr, 0,
+ std::string shared_class_expression;
+ llvm::raw_string_ostream(shared_class_expression) << llvm::format(
g_shared_cache_class_name_funcptr,
class_name_getter_function_name.AsCString(),
class_name_getter_function_name.AsCString());
- char *class_name_func_ptr_expr = (char*) malloc (prefix_string_size + 1);
- snprintf (class_name_func_ptr_expr, prefix_string_size + 1,
- g_shared_cache_class_name_funcptr,
- class_name_getter_function_name.AsCString(),
- class_name_getter_function_name.AsCString());
- std::string shared_class_expression = class_name_func_ptr_expr;
shared_class_expression += g_get_shared_cache_class_info_body;
- free (class_name_func_ptr_expr);
m_get_shared_cache_class_info_code.reset(
GetTargetRef().GetUtilityFunctionForLanguage(
More information about the lldb-commits
mailing list