Skip to content

Commit ad46441

Browse files
committed
do not allow strings containing null characters to be inlined (#2848)
1 parent c103602 commit ad46441

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

src/atom_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ impl AtomTable {
467467
}
468468

469469
pub fn build_with(atom_table: &AtomTable, string: &str) -> Atom {
470-
if 0 < string.len() && string.len() <= INLINED_ATOM_MAX_LEN {
470+
if 0 < string.len() && string.len() <= INLINED_ATOM_MAX_LEN && !string.contains('\u{0}') {
471471
return Atom::new_inlined(string);
472472
}
473473

src/loader.pl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@
177177

178178
filter_anonymous_vars([], []).
179179
filter_anonymous_vars([VN=V | VNEqs0], VNEqs) :-
180-
'$debug_hook',
181180
( atom_concat('_', _, VN) ->
182181
filter_anonymous_vars(VNEqs0, VNEqs)
183182
; VNEqs = [VN=V | VNEqs1],

src/types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ impl ConsPtr {
101101

102102
#[inline(always)]
103103
pub fn as_ptr(self) -> *mut u8 {
104-
unsafe { mem::transmute::<_, *mut u8>(self.ptr()) }
104+
let addr: u64 = self.ptr();
105+
addr as usize as *mut _
105106
}
106107

107108
#[inline(always)]

tests-pl/iso-conformity-tests.pl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,7 @@
761761

762762
test_229 :- test_syntax_error("\"\\z.\"", syntax_error(missing_quote)).
763763

764-
test_300 :- '$debug_hook',
765-
writeq_term_to_chars("\0\", C),
764+
test_300 :- writeq_term_to_chars("\0\", C),
766765
C == "['\\x0\\']".
767766

768767
test_172 :- X is 10.0** -323,

0 commit comments

Comments
 (0)