aboutsummaryrefslogtreecommitdiff
path: root/ext/misc/eval.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-12-05 00:32:09 +0000
committerdrh <drh@noemail.net>2014-12-05 00:32:09 +0000
commit2c3abeb8c3c01c8f0143557a3bebddf5d5d26405 (patch)
tree036ca226da4aad24b67051830424d3b0f607b2c7 /ext/misc/eval.c
parent5de7d966bd1bd61d4a197585db449bd111f60cab (diff)
downloadsqlite-2c3abeb8c3c01c8f0143557a3bebddf5d5d26405.tar.gz
sqlite-2c3abeb8c3c01c8f0143557a3bebddf5d5d26405.zip
Fix compiler warnings.
FossilOrigin-Name: e9955c0e14d13ba1411f013acb4979958dae2516
Diffstat (limited to 'ext/misc/eval.c')
-rw-r--r--ext/misc/eval.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/ext/misc/eval.c b/ext/misc/eval.c
index a5e297ad3..71b6b69f2 100644
--- a/ext/misc/eval.c
+++ b/ext/misc/eval.c
@@ -21,11 +21,11 @@ SQLITE_EXTENSION_INIT1
** Structure used to accumulate the output
*/
struct EvalResult {
- char *z; /* Accumulated output */
- const char *zSep; /* Separator */
- int szSep; /* Size of the separator string */
- int nAlloc; /* Number of bytes allocated for z[] */
- int nUsed; /* Number of bytes of z[] actually used */
+ char *z; /* Accumulated output */
+ const char *zSep; /* Separator */
+ int szSep; /* Size of the separator string */
+ sqlite3_int64 nAlloc; /* Number of bytes allocated for z[] */
+ sqlite3_int64 nUsed; /* Number of bytes of z[] actually used */
};
/*
@@ -37,10 +37,13 @@ static int callback(void *pCtx, int argc, char **argv, char **colnames){
for(i=0; i<argc; i++){
const char *z = argv[i] ? argv[i] : "";
size_t sz = strlen(z);
- if( sz+p->nUsed+p->szSep+1 > p->nAlloc ){
+ if( (sqlite3_int64)sz+p->nUsed+p->szSep+1 > p->nAlloc ){
char *zNew;
p->nAlloc = p->nAlloc*2 + sz + p->szSep + 1;
- zNew = sqlite3_realloc(p->z, p->nAlloc);
+ /* Using sqlite3_realloc64() would be better, but it is a recent
+ ** addition and will cause a segfault if loaded by an older version
+ ** of SQLite. */
+ zNew = p->nAlloc<=0x7fffffff ? sqlite3_realloc(p->z, (int)p->nAlloc) : 0;
if( zNew==0 ){
sqlite3_free(p->z);
memset(p, 0, sizeof(*p));
@@ -93,7 +96,7 @@ static void sqlEvalFunc(
sqlite3_result_error_nomem(context);
sqlite3_free(x.z);
}else{
- sqlite3_result_text(context, x.z, x.nUsed, sqlite3_free);
+ sqlite3_result_text(context, x.z, (int)x.nUsed, sqlite3_free);
}
}