@@ -22,13 +22,15 @@ #import "OFInvalidArgumentException.h" @implementation OFZIPURIHandler - (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode { + void *pool = objc_autoreleasePoolPush(); OFString *percentEncodedPath, *archiveURI, *path; size_t pos; OFZIPArchive *archive; + OFStream *stream; if (![URI.scheme isEqual: @"of-zip"] || URI.host != nil || URI.port != nil || URI.user != nil || URI.password != nil || URI.query != nil || URI.fragment != nil) @throw [OFInvalidArgumentException exception]; @@ -54,9 +56,14 @@ .stringByRemovingPercentEncoding; archive = [OFZIPArchive archiveWithURI: [OFURI URIWithString: archiveURI] mode: @"r"]; + stream = [archive streamForReadingFile: path]; + + [stream retain]; + + objc_autoreleasePoolPop(pool); - return [archive streamForReadingFile: path]; + return [stream autorelease]; } @end