fix use after free

This commit is contained in:
Folkert 2022-07-13 10:34:19 +02:00
parent 5f430034f3
commit 9a51737a47
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -1684,11 +1684,17 @@ pub fn fromUtf8Range(arg: RocList, start: usize, count: usize, update_mode: Upda
};
}
} else {
const temp = errorToProblem(@ptrCast([*]u8, arg.bytes), arg.length);
// decref the list
utils.decref(arg.bytes, arg.len(), 1);
const temp = errorToProblem(@ptrCast([*]u8, arg.bytes), arg.length);
return FromUtf8Result{ .is_ok = false, .string = RocStr.empty(), .byte_index = temp.index, .problem_code = temp.problem };
return FromUtf8Result{
.is_ok = false,
.string = RocStr.empty(),
.byte_index = temp.index,
.problem_code = temp.problem,
};
}
}