diff options
author | danielk1977 <danielk1977@noemail.net> | 2007-09-01 17:00:12 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2007-09-01 17:00:12 +0000 |
commit | d7d2f93cbbc43a55d9868159107206bde83c1309 (patch) | |
tree | d3d62b487e2e8073820723d248e8c2938e6610ca /src/func.c | |
parent | 843e65f2fce3ed601c017f82e4d55bcac028241b (diff) | |
download | sqlite-d7d2f93cbbc43a55d9868159107206bde83c1309.tar.gz sqlite-d7d2f93cbbc43a55d9868159107206bde83c1309.zip |
Remove code for calling the SQL function randstr() with 0 or 1 argument, as it is registered with sqlite as requiring exactly 2. Also test io errors in sqlite3_release_memory(). (CVS 4365)
FossilOrigin-Name: 5842f68c1ba838f24e9ba02c818d308540d591a4
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/func.c b/src/func.c index 6a8ea5682..334dfd9fb 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.172 2007/08/30 16:30:27 danielk1977 Exp $ +** $Id: func.c,v 1.173 2007/09/01 17:00:13 danielk1977 Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -1016,20 +1016,18 @@ static void randStr(sqlite3_context *context, int argc, sqlite3_value **argv){ ".-!,:*^+=_|?/<> "; int iMin, iMax, n, r, i; unsigned char zBuf[1000]; - if( argc>=1 ){ - iMin = sqlite3_value_int(argv[0]); - if( iMin<0 ) iMin = 0; - if( iMin>=sizeof(zBuf) ) iMin = sizeof(zBuf)-1; - }else{ - iMin = 1; - } - if( argc>=2 ){ - iMax = sqlite3_value_int(argv[1]); - if( iMax<iMin ) iMax = iMin; - if( iMax>=sizeof(zBuf) ) iMax = sizeof(zBuf)-1; - }else{ - iMax = 50; - } + + /* It used to be possible to call randstr() with any number of arguments, + ** but now it is registered with SQLite as requiring exactly 2. + */ + assert(argc==2); + + iMin = sqlite3_value_int(argv[0]); + if( iMin<0 ) iMin = 0; + if( iMin>=sizeof(zBuf) ) iMin = sizeof(zBuf)-1; + iMax = sqlite3_value_int(argv[1]); + if( iMax<iMin ) iMax = iMin; + if( iMax>=sizeof(zBuf) ) iMax = sizeof(zBuf)-1; n = iMin; if( iMax>iMin ){ sqlite3Randomness(sizeof(r), &r); |