]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make sure the random() function always returns a value that can be passed
authordrh <drh@noemail.net>
Thu, 23 Feb 2006 21:51:12 +0000 (21:51 +0000)
committerdrh <drh@noemail.net>
Thu, 23 Feb 2006 21:51:12 +0000 (21:51 +0000)
to abs(). (CVS 3109)

FossilOrigin-Name: 5d2e7ea01989fc9ba2c79d192760bc29f8cab463

manifest
manifest.uuid
src/func.c

index 20eea4f7b8e8953ab505c2b2774870bd9e79596a..7925a75ddbb0210c920dd911b17632bbdda01867 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Detect\sinteger\soverflow\sin\sthe\sabs()\sfunction.\s\sThe\srandom()\sfunction\nnow\sprovides\s64\sbits\sof\srandomness\sinstead\sof\sjust\s32.\s\sFix\sbugs\sin\ntesting\slogic\sof\stest4.c.\s(CVS\s3108)
-D 2006-02-23T21:43:56
+C Make\ssure\sthe\srandom()\sfunction\salways\sreturns\sa\svalue\sthat\scan\sbe\spassed\nto\sabs().\s(CVS\s3109)
+D 2006-02-23T21:51:13
 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -43,7 +43,7 @@ F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
 F src/delete.c ca404d5fd5f678e32f2f46377ad802cd0219aa99
 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
 F src/expr.c 9c957fabf95ef62288151eecd5c490a629470666
-F src/func.c b1919255cef5580ac1fcd555ee9bb96974bde64d
+F src/func.c 402b305b0f0d8709cce343e74312bcc38ed61f06
 F src/hash.c 449f3d6620193aa557f5d86cbc5cc6b87702b185
 F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
 F src/insert.c 67b3dc11831c58d8703eb502355ad3704ee18f66
@@ -354,7 +354,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 614fac906807b8c75e04effc01666874d13ce636
-R f5403923a4dc3e33ec17bd28655d7e3e
+P 942c509595a2a300e798e6b048ad7fc3bc54af43
+R 151d579d1c46dea292a923e2d9c89659
 U drh
-Z a926d16e02bacd004ff1a77e6671add9
+Z 630eeabb62dfd30a6a8a8d528960cacb
index 5b67994cb107d226332d4e46f748ad7a5db39e32..4e30a21cff200b4a719167fa74f34c74e3c8fae9 100644 (file)
@@ -1 +1 @@
-942c509595a2a300e798e6b048ad7fc3bc54af43
\ No newline at end of file
+5d2e7ea01989fc9ba2c79d192760bc29f8cab463
\ No newline at end of file
index be3fc943e175574376dedb8650661f197ce6fb9e..e365cc435c55fb5977dcead1960d925c7c8c9673 100644 (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);
 }