From 0e7294db8d100b4b97c654d3ffe3c1bae60aba6b Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 21 Jul 2015 19:57:18 +0300 Subject: [PATCH] Null-terminate all string literals. --- artiq/compiler/transforms/llvm_ir_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index fa7364b51..8405c147c 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -78,7 +78,7 @@ class LLVMIRGenerator: elif isinstance(const.value, (int, float)): return ll.Constant(llty, const.value) elif isinstance(const.value, str): - as_bytes = const.value.encode('utf-8') + as_bytes = (const.value + '\0').encode('utf-8') llstrty = ll.ArrayType(ll.IntType(8), len(as_bytes)) llconst = ll.GlobalVariable(self.llmodule, llstrty, name=self.llmodule.get_unique_name("str"))