1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-24 09:53:10 +03:00

Fix an NULL deref in the randomblob() function following a malloc failure. (CVS 3940)

FossilOrigin-Name: 011e7db253f9a60c19977215eab1687930f15637
This commit is contained in:
drh
2007-05-07 19:31:15 +00:00
parent 7de68a097e
commit 02d858364b
4 changed files with 19 additions and 14 deletions

View File

@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.145 2007/05/04 13:15:56 drh Exp $
** $Id: func.c,v 1.146 2007/05/07 19:31:16 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -297,9 +297,11 @@ static void randomBlob(
assert( argc==1 );
n = sqlite3_value_int(argv[0]);
if( n<1 ) n = 1;
p = sqlite3_malloc(n);
sqlite3Randomness(n, p);
sqlite3_result_blob(context, (char*)p, n, sqlite3_free);
p = sqliteMalloc(n);
if( p ){
sqlite3Randomness(n, p);
sqlite3_result_blob(context, (char*)p, n, sqlite3FreeX);
}
}
/*