Permalink
Browse files

Merge pull request #22 from jazzgumpy/master

Possible fix for issue #21
  • Loading branch information...
2 parents 540e643 + aae2b36 commit d2d6f213c10c7082b47664705f152341b739a5a9 @schwa schwa committed Apr 6, 2012
View
@@ -72,11 +72,11 @@ - (id)initWithXMLString:(NSString *)inString options:(NSUInteger)inOptions error
{
xmlErrorPtr theLastErrorPtr = xmlGetLastError();
- NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSString stringWithUTF8String:theLastErrorPtr->message], NSLocalizedDescriptionKey,
- NULL];
-
+ NSString* message = [NSString stringWithUTF8String:
+ (theLastErrorPtr ? theLastErrorPtr->message : "Unknown error")];
+ NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+ message, NSLocalizedDescriptionKey, NULL];
theError = [NSError errorWithDomain:@"CXMLErrorDomain" code:1 userInfo:theUserInfo];
xmlResetLastError();
@@ -75,6 +75,14 @@ - (void)test_badXMLTest
STAssertNotNil(theError, NULL);
}
+- (void)test_nilXMLTest
+{
+ NSError *theError = NULL;
+ CXMLDocument *theXMLDocument = [[[CXMLDocument alloc] initWithXMLString:nil options:0 error:&theError] autorelease];
+ STAssertNil(theXMLDocument, NULL);
+ STAssertNotNil(theError, NULL);
+}
+
- (void)test_badXMLTestFromData
{
NSError *theError = NULL;
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>SuppressBuildableAutocreation</key>
+ <dict>
+ <key>451E6E301152EB4A0024ABA5</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ <key>456A848A0D81DB06000E29C9</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ <key>457940FE0D82217800EB2D22</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ <key>457941040D82219400EB2D22</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ </dict>
+</dict>
+</plist>

0 comments on commit d2d6f21

Please sign in to comment.