do not allow strings containing null characters to be inlined (#2848)

This commit is contained in:
Mark Thom
2025-04-09 23:03:28 -07:00
committed by Mark Thom
parent 22080f3787
commit 98dae9aecc
4 changed files with 4 additions and 5 deletions

View File

@@ -467,7 +467,7 @@ impl AtomTable {
}
pub fn build_with(atom_table: &AtomTable, string: &str) -> Atom {
if 0 < string.len() && string.len() <= INLINED_ATOM_MAX_LEN {
if 0 < string.len() && string.len() <= INLINED_ATOM_MAX_LEN && !string.contains('\u{0}') {
return Atom::new_inlined(string);
}

View File

@@ -177,7 +177,6 @@ print_comma_separated_list([VN=_, VNEq | VNEqs]) :-
filter_anonymous_vars([], []).
filter_anonymous_vars([VN=V | VNEqs0], VNEqs) :-
'$debug_hook',
( atom_concat('_', _, VN) ->
filter_anonymous_vars(VNEqs0, VNEqs)
; VNEqs = [VN=V | VNEqs1],

View File

@@ -101,7 +101,8 @@ impl ConsPtr {
#[inline(always)]
pub fn as_ptr(self) -> *mut u8 {
unsafe { mem::transmute::<_, *mut u8>(self.ptr()) }
let addr: u64 = self.ptr();
addr as usize as *mut _
}
#[inline(always)]

View File

@@ -761,8 +761,7 @@ test_171 :- writeq_term_to_chars("a", C),
test_229 :- test_syntax_error("\"\\z.\"", syntax_error(missing_quote)).
test_300 :- '$debug_hook',
writeq_term_to_chars("\0\", C),
test_300 :- writeq_term_to_chars("\0\", C),
C == "['\\x0\\']".
test_172 :- X is 10.0** -323,