aboutsummaryrefslogtreecommitdiff
path: root/src/date.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/date.c')
-rw-r--r--src/date.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/date.c b/src/date.c
index d9b39b8b6..08ee30c38 100644
--- a/src/date.c
+++ b/src/date.c
@@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: date.c,v 1.86 2008/07/25 16:39:25 drh Exp $
+** $Id: date.c,v 1.87 2008/07/28 19:34:53 drh Exp $
**
** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon
@@ -849,9 +849,11 @@ static void strftimeFunc(
u64 n;
int i, j;
char *z;
+ sqlite3 *db;
const char *zFmt = (const char*)sqlite3_value_text(argv[0]);
char zBuf[100];
if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return;
+ db = sqlite3_context_db_handle(context);
for(i=0, n=1; zFmt[i]; i++, n++){
if( zFmt[i]=='%' ){
switch( zFmt[i+1] ){
@@ -887,11 +889,11 @@ static void strftimeFunc(
}
if( n<sizeof(zBuf) ){
z = zBuf;
- }else if( n>sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH] ){
+ }else if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){
sqlite3_result_error_toobig(context);
return;
}else{
- z = sqlite3Malloc( n );
+ z = sqlite3DbMallocRaw(db, n);
if( z==0 ){
sqlite3_result_error_nomem(context);
return;
@@ -956,7 +958,7 @@ static void strftimeFunc(
}
z[j] = 0;
sqlite3_result_text(context, z, -1,
- z==zBuf ? SQLITE_TRANSIENT : sqlite3_free);
+ z==zBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC);
}
/*