Browse files

Merge pull request #5 from aki-null/master

onig_new thread safety issue
  • Loading branch information...
2 parents 31755bc + 94bf31c commit e107c53f2a08e7a5e4e6770bb2e722d3e7c4d2b5 @psychs committed Apr 3, 2012
Showing with 10 additions and 7 deletions.
  1. +10 −7 framework/core/OnigRegexp.m
View
17 framework/core/OnigRegexp.m
@@ -114,13 +114,16 @@ + (OnigRegexp*)compile:(NSString*)expression options:(OnigOption)theOptions erro
regex_t* entity = 0;
const UChar* str = (const UChar*)[expression cStringUsingEncoding:STRING_ENCODING];
- int status = onig_new(&entity,
- str,
- str + [expression length] * CHAR_SIZE,
- option,
- ONIG_ENCODING,
- ONIG_SYNTAX_DEFAULT,
- &err);
+ int status;
+ @synchronized([OnigRegexp class]) {
+ status = onig_new(&entity,
+ str,
+ str + [expression length] * CHAR_SIZE,
+ option,
+ ONIG_ENCODING,
+ ONIG_SYNTAX_DEFAULT,
+ &err);
+ }
if (status == ONIG_NORMAL) {
return [[[self alloc] initWithEntity:entity expression:expression] autorelease];

0 comments on commit e107c53

Please sign in to comment.