Răsfoiți Sursa

Add edge case check for "" string

gingerBill 5 ani în urmă
părinte
comite
bf215377de
1 a modificat fișierele cu 3 adăugiri și 0 ștergeri
  1. 3 0
      src/llvm_backend.cpp

+ 3 - 0
src/llvm_backend.cpp

@@ -4895,6 +4895,9 @@ lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_loc
 			if (is_type_cstring(res.type)) {
 				res.value = ptr;
 			} else {
+				if (value.value_string.len == 0) {
+					ptr = LLVMConstNull(lb_type(m, t_u8_ptr));
+				}
 				LLVMValueRef str_len = LLVMConstInt(lb_type(m, t_int), value.value_string.len, true);
 				LLVMValueRef values[2] = {ptr, str_len};