/ Check-in [f5d9a806]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix memory leaks in Tcl user function interface. (CVS 2464)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f5d9a8061a6d650f207669b121243abb8dd28be2
User & Date: danielk1977 2005-05-20 09:40:56
Context
2005-05-20
19:36
Comment changes in vdbeapi.c (CVS 2465) check-in: ab7805fb user: drh tags: trunk
09:40
Fix memory leaks in Tcl user function interface. (CVS 2464) check-in: f5d9a806 user: danielk1977 tags: trunk
2005-05-19
08:43
Always use a more specific type (P3_FUNCDEF) instead of P3_POINTER as the P3 type of a vdbe instruction. (CVS 2463) check-in: 79a41674 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/tclsqlite.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** A TCL Interface to SQLite
    13     13   **
    14         -** $Id: tclsqlite.c,v 1.124 2005/05/05 10:30:30 drh Exp $
           14  +** $Id: tclsqlite.c,v 1.125 2005/05/20 09:40:56 danielk1977 Exp $
    15     15   */
    16     16   #ifndef NO_TCL     /* Omit this whole file if TCL is unavailable */
    17     17   
    18     18   #include "sqliteInt.h"
    19     19   #include "hash.h"
    20     20   #include "tcl.h"
    21     21   #include <stdlib.h>
................................................................................
   269    269         Tcl_DStringAppendElement(&cmd, "");
   270    270       }else{
   271    271         Tcl_DStringAppendElement(&cmd, sqlite3_value_text(argv[i]));
   272    272       }
   273    273     }
   274    274     rc = Tcl_EvalEx(p->interp, Tcl_DStringValue(&cmd), Tcl_DStringLength(&cmd),
   275    275                     TCL_EVAL_DIRECT);
          276  +  Tcl_DStringFree(&cmd);
          277  +
   276    278     if( rc && rc!=TCL_RETURN ){
   277    279       sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); 
   278    280     }else{
   279    281       Tcl_Obj *pVar = Tcl_GetObjResult(p->interp);
   280    282       int n;
   281    283       u8 *data;
   282    284       char *zType = pVar->typePtr ? pVar->typePtr->name : "";
   283    285       char c = zType[0];
   284    286       if( c=='b' && strcmp(zType,"bytearray")==0 ){
   285    287         data = Tcl_GetByteArrayFromObj(pVar, &n);
   286    288         sqlite3_result_blob(context, data, n, SQLITE_TRANSIENT);
   287         -      Tcl_IncrRefCount(pVar);
   288    289       }else if( (c=='b' && strcmp(zType,"boolean")==0) ||
   289    290             (c=='i' && strcmp(zType,"int")==0) ){
   290    291         Tcl_GetIntFromObj(0, pVar, &n);
   291    292         sqlite3_result_int(context, n);
   292    293       }else if( c=='d' && strcmp(zType,"double")==0 ){
   293    294         double r;
   294    295         Tcl_GetDoubleFromObj(0, pVar, &r);
   295    296         sqlite3_result_double(context, r);
   296    297       }else{
   297    298         data = Tcl_GetStringFromObj(pVar, &n);
   298    299         sqlite3_result_text(context, data, n, SQLITE_TRANSIENT);
   299         -      Tcl_IncrRefCount(pVar);
   300    300       }
   301    301     }
   302    302   }
   303    303   
   304    304   #ifndef SQLITE_OMIT_AUTHORIZATION
   305    305   /*
   306    306   ** This is the authentication function.  It appends the authentication