aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableContent.m
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-06-30 23:10:40 +0200
committerMax <post@wickenrode.com>2015-06-30 23:10:40 +0200
commit3c49b0f2bc16777f83cf57825448b6689ed344e1 (patch)
tree3abbf089b7794a1c81a4d9e483d94957ffbb16bd /Source/SPTableContent.m
parent6d372fabdf53b8d511da42fca1a7a00fb4950539 (diff)
downloadsequelpro-3c49b0f2bc16777f83cf57825448b6689ed344e1.tar.gz
sequelpro-3c49b0f2bc16777f83cf57825448b6689ed344e1.tar.bz2
sequelpro-3c49b0f2bc16777f83cf57825448b6689ed344e1.zip
Replace some malloc(a*b) with the safer calloc(a,b) variant
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r--Source/SPTableContent.m7
1 files changed, 4 insertions, 3 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 4cd21bb1..113bda45 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -65,6 +65,7 @@
#import <pthread.h>
#import <SPMySQL/SPMySQL.h>
+#include <stdlib.h>
#ifndef SP_CODA
static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOperator";
@@ -908,7 +909,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper
BOOL columnsFound = YES;
NSArray *primaryKeyFieldNames = [selectionToRestore objectForKey:@"keys"];
NSUInteger primaryKeyFieldCount = [primaryKeyFieldNames count];
- NSUInteger *primaryKeyFieldIndexes = malloc(primaryKeyFieldCount * sizeof(NSUInteger));
+ NSUInteger *primaryKeyFieldIndexes = calloc(primaryKeyFieldCount, sizeof(NSUInteger));
for (NSUInteger i = 0; i < primaryKeyFieldCount; i++) {
primaryKeyFieldIndexes[i] = [[tableDataInstance columnNames] indexOfObject:[primaryKeyFieldNames objectAtIndex:i]];
if (primaryKeyFieldIndexes[i] == NSNotFound) {
@@ -3696,7 +3697,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper
// Set up an array of the column indexes to store
NSUInteger primaryKeyFieldCount = [primaryKeyFieldNames count];
- NSUInteger *primaryKeyFieldIndexes = malloc(sizeof(NSUInteger) * primaryKeyFieldCount);
+ NSUInteger *primaryKeyFieldIndexes = calloc(primaryKeyFieldCount, sizeof(NSUInteger));
BOOL problemColumns = NO;
for (NSUInteger i = 0; i < primaryKeyFieldCount; i++) {
primaryKeyFieldIndexes[i] = [[tableDataInstance columnNames] indexOfObject:[primaryKeyFieldNames objectAtIndex:i]];
@@ -3716,7 +3717,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper
// Only proceed with key-based selection if there were no problem columns
if (!problemColumns) {
NSIndexSet *selectedRowIndexes = [tableContentView selectedRowIndexes];
- NSUInteger *indexBuffer = malloc(sizeof(NSUInteger) * [selectedRowIndexes count]);
+ NSUInteger *indexBuffer = calloc([selectedRowIndexes count], sizeof(NSUInteger));
NSUInteger indexCount = [selectedRowIndexes getIndexes:indexBuffer maxCount:[selectedRowIndexes count] inIndexRange:NULL];
NSMutableDictionary *selectedRowLookupTable = [NSMutableDictionary dictionaryWithCapacity:indexCount];