Bug 319453, r=vladimir: Bounds check GetBlob, return NULL if 0 size.

This commit is contained in:
brettw%gmail.com 2005-12-07 20:52:33 +00:00
Родитель c1c671891e
Коммит 7c77c3a347
2 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -85,6 +85,8 @@ interface mozIStorageValueArray : nsISupports {
double getDouble(in unsigned long aIndex); double getDouble(in unsigned long aIndex);
AUTF8String getUTF8String(in unsigned long aIndex); AUTF8String getUTF8String(in unsigned long aIndex);
AString getString(in unsigned long aIndex); AString getString(in unsigned long aIndex);
// data will be NULL if dataSize = 0
void getBlob(in unsigned long aIndex, out unsigned long aDataSize, [array,size_is(aDataSize)] out octet aData); void getBlob(in unsigned long aIndex, out unsigned long aDataSize, [array,size_is(aDataSize)] out octet aData);
boolean getIsNull(in unsigned long aIndex); boolean getIsNull(in unsigned long aIndex);

Просмотреть файл

@ -634,6 +634,12 @@ mozStorageStatement::GetBlob(PRUint32 aIndex, PRUint32 *aDataSize, PRUint8 **aDa
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
int blobsize = sqlite3_column_bytes (mDBStatement, aIndex); int blobsize = sqlite3_column_bytes (mDBStatement, aIndex);
if (blobsize == 0) {
// empty column
*aData = nsnull;
*aDataSize = 0;
return NS_OK;
}
const void *blob = sqlite3_column_blob (mDBStatement, aIndex); const void *blob = sqlite3_column_blob (mDBStatement, aIndex);
void *blobcopy = nsMemory::Clone(blob, blobsize); void *blobcopy = nsMemory::Clone(blob, blobsize);