mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Fix the readfile() UDF so that it returns an empty BLOB, not an OOM error,
when reading an empty file. FossilOrigin-Name: 0edad5339e36d69aed9289bb3e60d35f9930386d76a62bb0194c4fdf420d16fb
This commit is contained in:
@ -152,13 +152,13 @@ static void readFileContents(sqlite3_context *ctx, const char *zName){
|
||||
fclose(in);
|
||||
return;
|
||||
}
|
||||
pBuf = sqlite3_malloc64( nIn );
|
||||
pBuf = sqlite3_malloc64( nIn ? nIn : 1 );
|
||||
if( pBuf==0 ){
|
||||
sqlite3_result_error_nomem(ctx);
|
||||
fclose(in);
|
||||
return;
|
||||
}
|
||||
if( 1==fread(pBuf, nIn, 1, in) ){
|
||||
if( nIn==fread(pBuf, 1, nIn, in) ){
|
||||
sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free);
|
||||
}else{
|
||||
sqlite3_result_error_code(ctx, SQLITE_IOERR);
|
||||
|
Reference in New Issue
Block a user