mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
If sqlite3_column_value() is called to obtain a value with the MEM_Static flag set, clear it and set the MEM_Ephem flag before returning. Otherwise, if the value is passed to sqlite3_bind_value() or sqlite3_result_value(), sqlite may attempt to use the buffer after the statement has been finalized. This is not always valid, as MEM_Static only guarantees that a MEM.z buffer will be valid for the lifetime of the owner statement, not that it is actually a static buffer. (CVS 5812)
FossilOrigin-Name: b055bfc4e5268d8a66d6a4f5e8aec1285fe4b8e7
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
** This file contains code use to implement APIs that are part of the
|
||||
** VDBE.
|
||||
**
|
||||
** $Id: vdbeapi.c,v 1.146 2008/10/12 00:27:54 shane Exp $
|
||||
** $Id: vdbeapi.c,v 1.147 2008/10/13 10:37:50 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "vdbeInt.h"
|
||||
@@ -837,9 +837,13 @@ const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){
|
||||
return val;
|
||||
}
|
||||
sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){
|
||||
sqlite3_value *pOut = columnMem(pStmt, i);
|
||||
Mem *pOut = columnMem(pStmt, i);
|
||||
if( pOut->flags&MEM_Static ){
|
||||
pOut->flags &= ~MEM_Static;
|
||||
pOut->flags |= MEM_Ephem;
|
||||
}
|
||||
columnMallocFailure(pStmt);
|
||||
return pOut;
|
||||
return (sqlite3_value *)pOut;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_UTF16
|
||||
const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
|
||||
|
Reference in New Issue
Block a user