diff options
author | drh <drh@noemail.net> | 2006-02-23 21:51:12 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2006-02-23 21:51:12 +0000 |
commit | 874abbed6825c7a8b112ba941a3ff6fe1680210b (patch) | |
tree | 32f54f37b5da211d606a9ebe56ea0b6413737b88 /src/func.c | |
parent | 52fc849a3c623da3ff5f3a1499bb9fadd9b14f95 (diff) | |
download | sqlite-874abbed6825c7a8b112ba941a3ff6fe1680210b.tar.gz sqlite-874abbed6825c7a8b112ba941a3ff6fe1680210b.zip |
Make sure the random() function always returns a value that can be passed
to abs(). (CVS 3109)
FossilOrigin-Name: 5d2e7ea01989fc9ba2c79d192760bc29f8cab463
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/func.c b/src/func.c index be3fc943e..e365cc435 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.123 2006/02/23 21:43:56 drh Exp $ +** $Id: func.c,v 1.124 2006/02/23 21:51:13 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -266,6 +266,8 @@ static void randomFunc( ){ sqlite_int64 r; sqlite3Randomness(sizeof(r), &r); + if( (r<<1)==0 ) r = 0; /* Prevent 0x8000.... as the result so that we */ + /* can always do abs() of the result */ sqlite3_result_int64(context, r); } |