aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDataStorage.m
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-06-15 23:09:11 +0200
committerMax <post@wickenrode.com>2015-06-17 11:53:42 +0200
commit07a6789ae1f24fd41af801055f9d372ed4811251 (patch)
tree1f164fef1ee73ef934f009aa4def8db1e2ce8a95 /Source/SPDataStorage.m
parent84cfdf6028fe993e7225ed29938d1d5ed4c49bd4 (diff)
downloadsequelpro-07a6789ae1f24fd41af801055f9d372ed4811251.tar.gz
sequelpro-07a6789ae1f24fd41af801055f9d372ed4811251.tar.bz2
sequelpro-07a6789ae1f24fd41af801055f9d372ed4811251.zip
I have a feeling there might be a race condition lurking around hereā€¦
Diffstat (limited to 'Source/SPDataStorage.m')
-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;
}