aboutsummaryrefslogtreecommitdiff
path: root/src/func.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2007-05-07 19:31:15 +0000
committerdrh <drh@noemail.net>2007-05-07 19:31:15 +0000
commit02d858364b6e9a68ed6a21c5d642b2716539fca2 (patch)
tree148775663d445d7dda67810dd655a6f9fe905156 /src/func.c
parent7de68a097e1d4d8fa1b8e231156188300c4a7b1b (diff)
downloadsqlite-02d858364b6e9a68ed6a21c5d642b2716539fca2.tar.gz
sqlite-02d858364b6e9a68ed6a21c5d642b2716539fca2.zip
Fix an NULL deref in the randomblob() function following a malloc failure. (CVS 3940)
FossilOrigin-Name: 011e7db253f9a60c19977215eab1687930f15637
Diffstat (limited to 'src/func.c')
-rw-r--r--src/func.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/func.c b/src/func.c
index 5e4b418d5..2403b3d56 100644
--- a/src/func.c
+++ b/src/func.c
@@ -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);
+ }
}
/*