aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-06-15 23:09:11 +0200
committerMax <post@wickenrode.com>2015-06-15 23:09:11 +0200
commit0a2f79cf427e8b0cad9f9d70d705269f41181cdb (patch)
treefbcf0d06fc9988dfbe238f345e77289902ef4bdc /Source
parent73354646b9118f44f299425dd346425f584f7b48 (diff)
downloadsequelpro-0a2f79cf427e8b0cad9f9d70d705269f41181cdb.tar.gz
sequelpro-0a2f79cf427e8b0cad9f9d70d705269f41181cdb.tar.bz2
sequelpro-0a2f79cf427e8b0cad9f9d70d705269f41181cdb.zip
I have a feeling there might be a race condition lurking around hereā€¦
Diffstat (limited to 'Source')
-rw-r--r--Source/SPDataStorage.m9
1 files changed, 8 insertions, 1 deletions
diff --git a/Source/SPDataStorage.m b/Source/SPDataStorage.m
index dd5e87a5..17cc3a04 100644
--- a/Source/SPDataStorage.m
+++ b/Source/SPDataStorage.m
@@ -31,6 +31,7 @@
#import "SPDataStorage.h"
#import "SPObjectAdditions.h"
#import <SPMySQL/SPMySQLStreamingResultStore.h>
+#include <stdlib.h>
@interface SPDataStorage (Private_API)
@@ -80,7 +81,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore
[self resultStoreDidFinishLoadingData:dataStorage];
}
- unloadedColumns = malloc(numberOfColumns * sizeof(BOOL));
+ unloadedColumns = calloc(numberOfColumns, sizeof(BOOL));
for (i = 0; i < numberOfColumns; i++) {
unloadedColumns[i] = NO;
}
@@ -110,6 +111,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore
// Modify unloaded cells as appropriate
for (NSUInteger i = 0; i < numberOfColumns; i++) {
+ NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[i]) {
CFArraySetValueAtIndex((CFMutableArrayRef)dataArray, i, [SPNotLoaded notLoaded]);
}
@@ -138,6 +140,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore
}
// If the specified column is not loaded, return a SPNotLoaded reference
+ NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[columnIndex]) {
return [SPNotLoaded notLoaded];
}
@@ -172,6 +175,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore
}
// If the specified column is not loaded, return a SPNotLoaded reference
+ NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[columnIndex]) {
return [SPNotLoaded notLoaded];
}
@@ -199,6 +203,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore
[NSException raise:NSRangeException format:@"Requested storage column (col %llu) beyond bounds (%llu)", (unsigned long long)columnIndex, (unsigned long long)numberOfColumns];
}
+ NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[columnIndex]) {
return YES;
}
@@ -232,6 +237,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore
// Modify unloaded cells as appropriate
for (NSUInteger i = 0; i < numberOfColumns; i++) {
+ NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
if (unloadedColumns[i]) {
CFArraySetValueAtIndex((CFMutableArrayRef)targetRow, i, [SPNotLoaded notLoaded]);
}
@@ -391,6 +397,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore
if (columnIndex >= numberOfColumns) {
[NSException raise:NSRangeException format:@"Invalid column set as unloaded; requested column index (%llu) beyond bounds (%llu)", (unsigned long long)columnIndex, (unsigned long long)numberOfColumns];
}
+ NSAssert(unloadedColumns != NULL, @"unloadedColumns not loaded!");
unloadedColumns[columnIndex] = YES;
}