Browse files

Small fixes.

  • Loading branch information...
1 parent 6976d2b commit ea109806543e689209007a32d609510c5e319898 @logancollins committed Oct 11, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 Mocha/MochaRuntime.m
View
7 Mocha/MochaRuntime.m
@@ -689,9 +689,12 @@ - (BOOL)isSyntaxValidForString:(NSString *)string {
#pragma mark Exceptions
+ (NSException *)exceptionWithJSException:(JSValueRef)exception context:(JSContextRef)ctx {
+ NSString *error = nil;
JSStringRef resultStringJS = JSValueToStringCopy(ctx, exception, NULL);
- NSString *error = (NSString *)CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, resultStringJS));
- JSStringRelease(resultStringJS);
+ if (resultStringJS != NULL) {
+ error = (NSString *)CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, resultStringJS));
+ JSStringRelease(resultStringJS);
+ }
if (JSValueGetType(ctx, exception) != kJSTypeObject) {
NSException *mochaException = [NSException exceptionWithName:MOJavaScriptException reason:error userInfo:nil];

0 comments on commit ea10980

Please sign in to comment.