From 9efe4d77b7391e4cd56d67fcb7616f24c597ca6b Mon Sep 17 00:00:00 2001
From: "Jay Freeman (saurik)" <saurik@saurik.com>
Date: Sun, 28 Feb 2010 22:52:58 +0000
Subject: [PATCH] Checkpoint.

---
 LockScreen.mm | 14 +++++++++-----
 control       |  2 +-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/LockScreen.mm b/LockScreen.mm
index b350935..ccba730 100644
--- a/LockScreen.mm
+++ b/LockScreen.mm
@@ -996,6 +996,7 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6
 @interface CydgetPHPURLProtocol : NSURLProtocol {
     pid_t pid_;
     CFHTTPMessageRef http_;
+    NSFileHandle *handle_;
 }
 
 @end
@@ -1073,18 +1074,17 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6
     http_ = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE);
     CFHTTPMessageAppendBytes(http_, (const uint8_t *) "HTTP/1.1 200 OK\r\n", 17);
 
-    NSFileHandle *handle([[NSFileHandle alloc] initWithFileDescriptor:fds[0] closeOnDealloc:YES]);
+    _assert(handle_ == nil);
+    handle_ = [[NSFileHandle alloc] initWithFileDescriptor:fds[0] closeOnDealloc:YES];
 
     [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(onRead:)
         name:@"NSFileHandleReadCompletionNotification"
-        object:handle
+        object:handle_
     ];
 
-    [handle readInBackgroundAndNotify];
-
-    [handle release];
+    [handle_ readInBackgroundAndNotify];
 }
 
 - (void) onRead:(NSNotification *)notification {
@@ -1124,6 +1124,10 @@ MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6
     //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
 
 - (void) stopLoading {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    [handle_ release];
+    handle_ = nil;
+
     if (pid_ != -1) {
         kill(pid_, SIGTERM);
         int status;
diff --git a/control b/control
index dc4a9f4..c7502ac 100644
--- a/control
+++ b/control
@@ -3,7 +3,7 @@ Priority: optional
 Section: Development
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 0.9.3106-1
+Version: 0.9.3107-1
 Description: framework for managing lock screen plugins
 Name: Cydget
 Depends: mobilesubstrate (>= 0.9.2587-1), firmware (>= 2.2), preferenceloader, apr-lib, pcre, cycript (>= 0.9.292-1)
-- 
2.47.2