From 97cbdc3e3ece32a6e851764b50b3f1f8166df461 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 28 May 2008 14:29:14 -0400 Subject: [PATCH] Trying to add some bounds checking so we don't get unhandled exceptions * Source/DebuggerConnection.m: (-[processData:]): Try to catch malformed data * Source/DebuggerWindowController.m: (-[updateSourceViewer]): Don't proceed if there is no stack --- Source/DebuggerConnection.m | 12 +++++++++++- Source/DebuggerWindowController.m | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index e1a9c0c..8a94e03 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -271,7 +271,17 @@ */ - (NSXMLDocument *)processData:(NSData *)data { - NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData:data options:NSXMLDocumentTidyXML error:nil]; + NSXMLDocument *doc; + + @try + { + doc = [[NSXMLDocument alloc] initWithData:data options:NSXMLDocumentTidyXML error:nil]; + } + @catch (NSException *e) + { + NSLog(@"Could not parse XML? --- %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + return nil; + } // check and see if there's an error NSArray *error = [[doc rootElement] elementsForName:@"error"]; diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index 6f02f50..1822046 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -216,6 +216,12 @@ } int selection = [selectedLevel intValue]; + if ([stack count] < 1) + { + NSLog(@"huh... we don't have a stack"); + return; + } + // get the filename and then set the text NSString *filename = [[stack objectAtIndex:selection] valueForKey:@"filename"]; filename = [[NSURL URLWithString:filename] path]; -- 2.43.5