forked from M-Labs/artiq
1
0
Fork 0

Null-terminate all string literals.

This commit is contained in:
whitequark 2015-07-21 19:57:18 +03:00
parent 9d20080624
commit 0e7294db8d
1 changed files with 1 additions and 1 deletions

View File

@ -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"))