From 96872fc9563c747ef66a1535a8db8b07439daa13 Mon Sep 17 00:00:00 2001 From: Stuart Connolly Date: Sun, 26 Jan 2014 14:50:33 +0000 Subject: Fix PostgresKit memory leaks. --- Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m | 6 +++++- Frameworks/PostgresKit/Source/PGPostgresTypeDateTimeHandler.m | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'Frameworks/PostgresKit/Source') diff --git a/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m b/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m index 7e0aa18a..909e5451 100644 --- a/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m +++ b/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m @@ -219,7 +219,11 @@ PGQueryParamData; if (![statement name]) { BOOL prepareResult = [self _prepare:statement num:paramData->paramNum types:paramData->paramTypes]; - if (!prepareResult || ![statement name]) return nil; + if (!prepareResult || ![statement name]) { + [self _destroyParamDataStructure:paramData]; + + return nil; + } } pgResult = PQexecPrepared(_connection, diff --git a/Frameworks/PostgresKit/Source/PGPostgresTypeDateTimeHandler.m b/Frameworks/PostgresKit/Source/PGPostgresTypeDateTimeHandler.m index eb206587..cb09176e 100644 --- a/Frameworks/PostgresKit/Source/PGPostgresTypeDateTimeHandler.m +++ b/Frameworks/PostgresKit/Source/PGPostgresTypeDateTimeHandler.m @@ -113,7 +113,7 @@ static PGPostgresOid PGPostgresTypeDateTimeTypes[] = if (!PQgetf(_result, (int)_row, PGPostgresResultValueDate, (int)_column, &date)) return [NSNull null]; - NSDateComponents *components = [[NSDateComponents alloc] init]; + NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease]; [components setDay:date.mday]; [components setMonth:date.mon + 1]; // Months are indexed from 0 @@ -151,7 +151,7 @@ static PGPostgresOid PGPostgresTypeDateTimeTypes[] = if (!PQgetf(_result, (int)_row, hasTimeZone ? PGPostgresResultValueTimeTZ : PGPostgresResultValueTime, (int)_column, &pgTime)) return [NSNull null]; - NSDateComponents *components = [[NSDateComponents alloc] init]; + NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease]; // Default date values; should be ignored [components setDay:1]; -- cgit v1.2.3