From 736eb746df051d78de1b8cfc7733c614b39c157c Mon Sep 17 00:00:00 2001 From: rfm Date: Mon, 10 Apr 2017 14:49:17 +0000 Subject: [PATCH] Fixup another memory management issue git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@40463 72102866-910b-0410-8b05-ffd578937521 --- SQLClient.m | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/SQLClient.m b/SQLClient.m index 2eb28cd..6aa2ac3 100644 --- a/SQLClient.m +++ b/SQLClient.m @@ -993,6 +993,7 @@ static int poolConnections = 0; if (Nil == LitStringClass) { Class root = [NSObject class]; + SEL sel; /* Find the literal string class used by the foundation library. */ @@ -1007,18 +1008,40 @@ static int poolConnections = 0; /* The the NSObject memory management methods because the * literal string doesn't get retained/released. */ - class_replaceMethod(SQLStringClass, @selector(retain), + + sel = @selector(retain); + class_replaceMethod(SQLStringClass, sel, + class_getMethodImplementation(root, sel), + method_getTypeEncoding(class_getInstanceMethod(root, sel))); + + sel = @selector(release); + class_replaceMethod(SQLStringClass, sel, + class_getMethodImplementation(root, sel), + method_getTypeEncoding(class_getInstanceMethod(root, sel))); + + sel = @selector(autorelease); + class_replaceMethod(SQLStringClass, sel, + class_getMethodImplementation(root, sel), + method_getTypeEncoding(class_getInstanceMethod(root, sel))); + + sel = @selector(dealloc); + class_replaceMethod(SQLStringClass, sel, + class_getMethodImplementation(root, sel), + method_getTypeEncoding(class_getInstanceMethod(root, sel))); + + /* The -copy and -copyWithZone: methods should simply retain + * the receiver. + */ + sel = @selector(copy); + class_replaceMethod(SQLStringClass, sel, class_getMethodImplementation(root, @selector(retain)), - "@@:"); - class_replaceMethod(SQLStringClass, @selector(autorelease), - class_getMethodImplementation(root, @selector(autorelease)), - "@@:"); - class_replaceMethod(SQLStringClass, @selector(release), - class_getMethodImplementation(root, @selector(release)), - "v@:"); - class_replaceMethod(SQLStringClass, @selector(dealloc), - class_getMethodImplementation(root, @selector(dealloc)), - "v@:"); + method_getTypeEncoding(class_getInstanceMethod(root, sel))); + + sel = @selector(copyWithZone:); + class_replaceMethod(SQLStringClass, sel, + class_getMethodImplementation(root, @selector(retain)), + method_getTypeEncoding(class_getInstanceMethod(root, sel))); + } if (nil == null)