1
0
Fork 0
mirror of https://github.com/azalea-rs/simdnbt.git synced 2025-08-02 07:26:04 +00:00

fix: convert array len to u32 before writing

This commit is contained in:
amyavi 2024-08-04 00:50:25 -03:00
parent 6d23e4e481
commit c23e2ae43b
No known key found for this signature in database
2 changed files with 6 additions and 6 deletions

View file

@ -471,7 +471,7 @@ pub(crate) fn write_tag(tag: NbtTag, data: &mut Vec<u8>) {
TapeTagKind::ByteArray => {
let byte_array = tag.byte_array().unwrap();
unsafe {
unchecked_extend(data, &byte_array.len().to_be_bytes());
unchecked_extend(data, &(byte_array.len() as u32).to_be_bytes());
}
data.extend_from_slice(byte_array);
}
@ -489,7 +489,7 @@ pub(crate) fn write_tag(tag: NbtTag, data: &mut Vec<u8>) {
let int_array =
unsafe { list::u32_prefixed_list_to_rawlist_unchecked::<i32>(el.ptr()).unwrap() };
unsafe {
unchecked_extend(data, &int_array.len().to_be_bytes());
unchecked_extend(data, &(int_array.len() as u32).to_be_bytes());
}
data.extend_from_slice(int_array.as_big_endian());
}
@ -497,7 +497,7 @@ pub(crate) fn write_tag(tag: NbtTag, data: &mut Vec<u8>) {
let long_array =
unsafe { list::u32_prefixed_list_to_rawlist_unchecked::<i64>(el.ptr()).unwrap() };
unsafe {
unchecked_extend(data, &long_array.len().to_be_bytes());
unchecked_extend(data, &(long_array.len() as u32).to_be_bytes());
}
data.extend_from_slice(long_array.as_big_endian());
}

View file

@ -347,7 +347,7 @@ impl NbtTag {
}
NbtTag::ByteArray(byte_array) => {
unsafe {
unchecked_extend(data, &byte_array.len().to_be_bytes());
unchecked_extend(data, &(byte_array.len() as u32).to_be_bytes());
}
data.extend_from_slice(byte_array);
}
@ -362,13 +362,13 @@ impl NbtTag {
}
NbtTag::IntArray(int_array) => {
unsafe {
unchecked_extend(data, &int_array.len().to_be_bytes());
unchecked_extend(data, &(int_array.len() as u32).to_be_bytes());
}
data.extend_from_slice(&slice_into_u8_big_endian(int_array));
}
NbtTag::LongArray(long_array) => {
unsafe {
unchecked_extend(data, &long_array.len().to_be_bytes());
unchecked_extend(data, &(long_array.len() as u32).to_be_bytes());
}
data.extend_from_slice(&slice_into_u8_big_endian(long_array));
}