Skip to content

Commit c0fdb5f

Browse files
lbonnNWilson
authored andcommitted
Fix locking region in sjlit_malloc_exec
Cherry-picked from ad89dd8ecd25589d236bd20b36f2abf69f938fd1 (https://github.com/zherczeg/sljit.git) The locked section needs to extend until we are done modifying internal block offsets and sizes, otherwise we risk running into data corruption in a multi-threaded context. This bug was introduced in 7de0fee9a7376b33e31a3903487cd9933da3a606
1 parent 3864abd commit c0fdb5f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/sljit/allocator_src/sljitExecAllocatorCore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
237237
header->size = chunk_size;
238238
next_header = AS_BLOCK_HEADER(header, chunk_size);
239239
}
240-
SLJIT_ALLOCATOR_UNLOCK();
241240
next_header->size = 1;
242241
next_header->prev_size = chunk_size;
243242
#ifdef SLJIT_HAS_EXECUTABLE_OFFSET
244243
next_header->executable_offset = executable_offset;
245244
#endif /* SLJIT_HAS_EXECUTABLE_OFFSET */
245+
SLJIT_ALLOCATOR_UNLOCK();
246246
return MEM_START(header);
247247
}
248248

0 commit comments

Comments
 (0)