From d2018032597822db4cb4eaa24eb0f950a29fc9b3 Mon Sep 17 00:00:00 2001 From: Andy Matuschak Date: Wed, 3 Sep 2008 22:34:25 -0500 Subject: [PATCH] More fixes for 258060 Fixes a bug which could cause a crash when the update item is chosen by the delegate from the appcast. Thanks, Christiaan Hofman. --- SUBasicUpdateDriver.m | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index 70ffb759..eb974c2d 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -79,22 +79,24 @@ { if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) [[updater delegate] updater:updater didFinishLoadingAppcast:ac]; - + + SUAppcastItem *item = nil; + // Now we have to find the best valid update in the appcast. if ([[updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it? { - updateItem = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:updater]; + item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:updater]; } else // If not, we'll take care of it ourselves. { // Find the first update we can actually use. NSEnumerator *updateEnumerator = [[ac items] objectEnumerator]; do { - updateItem = [updateEnumerator nextObject]; - } while (updateItem && ![self hostSupportsItem:updateItem]); - - [updateItem retain]; + item = [updateEnumerator nextObject]; + } while (item && ![self hostSupportsItem:item]); } + + updateItem = [item retain]; CFRelease(ac); // Remember that we're explicitly managing the memory of the appcast. if (updateItem == nil) { [self didNotFindUpdate]; return; }