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

Make sure the random() function always returns a value that can be passed

to abs(). (CVS 3109)

FossilOrigin-Name: 5d2e7ea01989fc9ba2c79d192760bc29f8cab463
This commit is contained in:
drh
2006-02-23 21:51:12 +00:00
parent 52fc849a3c
commit 874abbed68
3 changed files with 10 additions and 8 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.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);
}