Skip to content

Commit df233ae

Browse files
authored
Merge pull request #1760 from Kelimion/xxh3_fix
[xxh3] Fix flaws in streaming implementation
2 parents 6ade9ac + 335b724 commit df233ae

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

core/hash/xxhash/streaming.odin

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ XXH3_128_reset_with_seed :: proc(state: ^XXH3_state, seed: XXH64_hash) -> (err:
5252
XXH3_64_reset_with_seed :: XXH3_128_reset_with_seed
5353

5454
XXH3_128_update :: proc(state: ^XXH3_state, input: []u8) -> (err: Error) {
55-
if len(input) < XXH3_MIDSIZE_MAX {
56-
return .Error
57-
}
5855
return XXH3_update(state, input, XXH3_accumulate_512, XXH3_scramble_accumulator)
5956
}
6057
XXH3_64_update :: XXH3_128_update
@@ -127,6 +124,7 @@ XXH3_create_state :: proc(allocator := context.allocator) -> (res: ^XXH3_state,
127124
err = nil if mem_error == nil else .Error
128125

129126
XXH3_init_state(state)
127+
XXH3_128_reset(state)
130128
return state, nil
131129
}
132130

@@ -234,7 +232,9 @@ XXH3_update :: #force_inline proc(
234232
*/
235233
if state.buffered_size > 0 {
236234
load_size := int(XXH3_INTERNAL_BUFFER_SIZE - state.buffered_size)
237-
mem_copy(&state.buffer[state.buffered_size], &input[0], load_size)
235+
236+
state_ptr := rawptr(uintptr(raw_data(state.buffer[:])) + uintptr(state.buffered_size))
237+
mem_copy(state_ptr, raw_data(input), load_size)
238238
input = input[load_size:]
239239

240240
XXH3_consume_stripes(

0 commit comments

Comments
 (0)