mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix not freeing a zero length String
This commit is contained in:
@@ -526,6 +526,11 @@ fn String String.tconcat(s1, String s2) => s1.concat(s2, allocator::temp());
|
||||
|
||||
fn ZString String.zstr_tcopy(s) => s.zstr_copy(allocator::temp()) @inline;
|
||||
|
||||
<*
|
||||
Copy this string, by duplicating the string, always adding a zero byte
|
||||
sentinel, so that it safely can be converted to a ZString by a
|
||||
cast.
|
||||
*>
|
||||
fn String String.copy(s, Allocator allocator = allocator::heap())
|
||||
{
|
||||
usz len = s.len;
|
||||
@@ -537,7 +542,7 @@ fn String String.copy(s, Allocator allocator = allocator::heap())
|
||||
|
||||
fn void String.free(&s, Allocator allocator = allocator::heap())
|
||||
{
|
||||
if (!s.len) return;
|
||||
if (!s.ptr) return;
|
||||
allocator::free(allocator, s.ptr);
|
||||
*s = "";
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
- Assert on certain slice to slice casts. #1768.
|
||||
- Fix vector float -> bool conversion.
|
||||
- Fix `+a = 1` erronously being accepted.
|
||||
- Fix not freeing a zero length String
|
||||
|
||||
### Stdlib changes
|
||||
- Increase BitWriter.write_bits limit up to 32 bits.
|
||||
|
||||
@@ -3083,7 +3083,6 @@ static void gencontext_emit_slice(GenContext *c, BEValue *be_value, Expr *expr)
|
||||
llvm_value_rvalue(c, &start);
|
||||
llvm_value_rvalue(c, &end);
|
||||
|
||||
|
||||
// Calculate the size
|
||||
LLVMValueRef size;
|
||||
if (is_exclusive)
|
||||
@@ -3268,11 +3267,7 @@ static void llvm_emit_slice_assign(GenContext *c, BEValue *be_value, Expr *expr)
|
||||
llvm_emit_br(c, cond_block);
|
||||
|
||||
// Finally set up our phi
|
||||
if (!assign_block_end)
|
||||
{
|
||||
offset = start.value;
|
||||
}
|
||||
else
|
||||
if (assign_block_end)
|
||||
{
|
||||
llvm_set_phi(offset, start.value, start_block, next_offset, assign_block_end);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user