From 07a6789ae1f24fd41af801055f9d372ed4811251 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 15 Jun 2015 23:09:11 +0200 Subject: =?UTF-8?q?I=20have=20a=20feeling=20there=20might=20be=20a=20race?= =?UTF-8?q?=20condition=20lurking=20around=20here=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPDataStorage.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Source') 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 +#include @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; } -- cgit v1.2.3