Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #5 from aki-null/master

onig_new thread safety issue
  • Loading branch information...
commit e107c53f2a08e7a5e4e6770bb2e722d3e7c4d2b5 2 parents 31755bc + 94bf31c
Satoshi Nakagawa authored

Showing 1 changed file with 10 additions and 7 deletions. Show diff stats Hide diff stats

  1. +10 7 framework/core/OnigRegexp.m
17 framework/core/OnigRegexp.m
@@ -114,13 +114,16 @@ + (OnigRegexp*)compile:(NSString*)expression options:(OnigOption)theOptions erro
114 114 regex_t* entity = 0;
115 115 const UChar* str = (const UChar*)[expression cStringUsingEncoding:STRING_ENCODING];
116 116
117   - int status = onig_new(&entity,
118   - str,
119   - str + [expression length] * CHAR_SIZE,
120   - option,
121   - ONIG_ENCODING,
122   - ONIG_SYNTAX_DEFAULT,
123   - &err);
  117 + int status;
  118 + @synchronized([OnigRegexp class]) {
  119 + status = onig_new(&entity,
  120 + str,
  121 + str + [expression length] * CHAR_SIZE,
  122 + option,
  123 + ONIG_ENCODING,
  124 + ONIG_SYNTAX_DEFAULT,
  125 + &err);
  126 + }
124 127
125 128 if (status == ONIG_NORMAL) {
126 129 return [[[self alloc] initWithEntity:entity expression:expression] autorelease];

0 comments on commit e107c53

Please sign in to comment.
Something went wrong with that request. Please try again.