[llvm] 5528784 - [ORC][examples] Fix off-by-one error when handling null terminators.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Fri May 20 20:26:52 PDT 2022
Author: Lang Hames
Date: 2022-05-20T19:33:49-07:00
New Revision: 55287840fe3f0d175ca649f0b665ccc0c184eb5d
URL: https://github.com/llvm/llvm-project/commit/55287840fe3f0d175ca649f0b665ccc0c184eb5d
DIFF: https://github.com/llvm/llvm-project/commit/55287840fe3f0d175ca649f0b665ccc0c184eb5d.diff
LOG: [ORC][examples] Fix off-by-one error when handling null terminators.
LLVMCreateMemoryBufferWithMemoryRange checks for a null terminator after the
given range, so we need to pass the length of the module string (excluding the
null terminator).
Added:
Modified:
llvm/examples/OrcV2Examples/OrcV2CBindingsLazy/OrcV2CBindingsLazy.c
Removed:
################################################################################
diff --git a/llvm/examples/OrcV2Examples/OrcV2CBindingsLazy/OrcV2CBindingsLazy.c b/llvm/examples/OrcV2Examples/OrcV2CBindingsLazy/OrcV2CBindingsLazy.c
index 0f4f979127e85..fd90671bbb344 100644
--- a/llvm/examples/OrcV2Examples/OrcV2CBindingsLazy/OrcV2CBindingsLazy.c
+++ b/llvm/examples/OrcV2Examples/OrcV2CBindingsLazy/OrcV2CBindingsLazy.c
@@ -127,8 +127,8 @@ int main(int argc, char *argv[]) {
LLVMErrorRef Err;
LLVMOrcThreadSafeModuleRef FooTSM;
- if ((Err =
- parseExampleModule(FooMod, sizeof(FooMod), "foo-mod", &FooTSM))) {
+ if ((Err = parseExampleModule(FooMod, sizeof(FooMod) - 1, "foo-mod",
+ &FooTSM))) {
MainResult = handleError(Err);
goto jit_cleanup;
}
@@ -142,8 +142,8 @@ int main(int argc, char *argv[]) {
}
LLVMOrcThreadSafeModuleRef BarTSM;
- if ((Err =
- parseExampleModule(BarMod, sizeof(BarMod), "bar-mod", &BarTSM))) {
+ if ((Err = parseExampleModule(BarMod, sizeof(BarMod) - 1, "bar-mod",
+ &BarTSM))) {
MainResult = handleError(Err);
goto jit_cleanup;
}
@@ -155,7 +155,7 @@ int main(int argc, char *argv[]) {
}
LLVMOrcThreadSafeModuleRef MainTSM;
- if ((Err = parseExampleModule(MainMod, sizeof(MainMod), "main-mod",
+ if ((Err = parseExampleModule(MainMod, sizeof(MainMod) - 1, "main-mod",
&MainTSM))) {
MainResult = handleError(Err);
goto jit_cleanup;
More information about the llvm-commits
mailing list