title: sqlite3_column_text returned data gets corrupted during finalize/close
body: <p>I'm not sure what's happening here but I'm finding that the returned data from sqlite3_column_text is being altered during the finalize/close sqlite stage.</p>
  
  <pre><code>  // rc not handled in this abbreviated code
  
    sqlite3 *db;
    sqlite3_stmt *stmt;
    char * sql;
  
    const char * tail;
    int rc;
  
    char * dbName = "C:\\db\\myblobs.db";
    int myIndex = 0;
  
    char * myLocation1;
    string myLocation2;   
  
    rc = sqlite3_open(dbName, &amp;db);
  
    sql = "SELECT location FROM blobs WHERE key = ?";
    rc = sqlite3_prepare(db, sql, strlen(sql), &amp;stmt, &amp;tail);
    sqlite3_bind_int(stmt, 1, myIndex);
    rc = sqlite3_step(stmt);
  
    myLocation1 = (char*)sqlite3_column_text(stmt, 0);
    myLocation2 = (char*)sqlite3_column_text(stmt, 0);
  
    // can process myLocation1 &amp; myLocation2 fine here
  
    sqlite3_finalize(stmt); // data myLocation1 points to get corrupted
    sqlite3_close(db);      // data myLocation2 points to gets further corrupted
  </code></pre>
  
  <p>The problem is in relation to myLocation1. The data it points to is fine until it hits the sqlite3_finalize and sqlite3_close statements. However mylocation2 remains unaltered. So not sure what's happening here. After executing sqlite3_close(db), myLocation1 is identified as a "Bad Ptr" within Visual Studio 2010. </p>
  
  <p>Any help most appreciated.</p>