@@ -14848,8 +14848,31 @@ pcre2_jit_compile(pcre2_code *code, uint32_t options)
14848
14848
{
14849
14849
pcre2_real_code * re = (pcre2_real_code * )code ;
14850
14850
#ifdef SUPPORT_JIT
14851
+ void * exec_memory ;
14851
14852
executable_functions * functions ;
14852
14853
static int executable_allocator_is_working = -1 ;
14854
+
14855
+ if (executable_allocator_is_working == -1 )
14856
+ {
14857
+ /* Checks whether the executable allocator is working. This check
14858
+ might run multiple times in multi-threaded environments, but the
14859
+ result should not be affected by it. */
14860
+ exec_memory = SLJIT_MALLOC_EXEC (32 , NULL );
14861
+ if (exec_memory != NULL )
14862
+ {
14863
+ SLJIT_FREE_EXEC (((sljit_u8 * )(exec_memory )) + SLJIT_EXEC_OFFSET (exec_memory ), NULL );
14864
+ executable_allocator_is_working = 1 ;
14865
+ }
14866
+ else executable_allocator_is_working = 0 ;
14867
+ }
14868
+
14869
+ if (options & PCRE2_JIT_TEST_ALLOC )
14870
+ {
14871
+ if (options != PCRE2_JIT_TEST_ALLOC )
14872
+ return PCRE2_ERROR_JIT_BADOPTION ;
14873
+
14874
+ return executable_allocator_is_working ? 0 : PCRE2_ERROR_NOMEMORY ;
14875
+ }
14853
14876
#endif
14854
14877
14855
14878
if (code == NULL )
@@ -14912,20 +14935,6 @@ return PCRE2_ERROR_JIT_BADOPTION;
14912
14935
14913
14936
if ((re -> flags & PCRE2_NOJIT ) != 0 ) return 0 ;
14914
14937
14915
- if (executable_allocator_is_working == -1 )
14916
- {
14917
- /* Checks whether the executable allocator is working. This check
14918
- might run multiple times in multi-threaded environments, but the
14919
- result should not be affected by it. */
14920
- void * ptr = SLJIT_MALLOC_EXEC (32 , NULL );
14921
- if (ptr != NULL )
14922
- {
14923
- SLJIT_FREE_EXEC (((sljit_u8 * )(ptr )) + SLJIT_EXEC_OFFSET (ptr ), NULL );
14924
- executable_allocator_is_working = 1 ;
14925
- }
14926
- else executable_allocator_is_working = 0 ;
14927
- }
14928
-
14929
14938
if (!executable_allocator_is_working )
14930
14939
return PCRE2_ERROR_NOMEMORY ;
14931
14940
0 commit comments