зеркало из https://github.com/mozilla/pjs.git
Bug 319453, r=vladimir: Bounds check GetBlob, return NULL if 0 size.
This commit is contained in:
Родитель
7525ea8f61
Коммит
06c9dac0ff
|
@ -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);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче