You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by David Glasser <gl...@mit.edu> on 2007/06/07 15:43:05 UTC

[PATCH] fix sqlite error message leak

Reading through the sqlite3 API, it appears that the caller of
sqlite3_exec is responsible for freeing any error message string that
is returned.  The following patch does this for the mergeinfo code.
Since this is my first time working with the mergeinfo code or sqlite3
in general, I'm posting this for review instead of just committing.

--dave

[[[
* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c
  (util_sqlite_exec): Don't leak the error string returned from
   sqlite3_exec.
]]]

-- 
David Glasser | glasser@mit.edu | http://www.davidglasser.net/

Re: [PATCH] fix sqlite error message leak

Posted by Daniel Rall <dl...@collab.net>.
Patch looks conceptually great, but the formatting's inconsistent with
SVN's style.  +1 to commit after tweaking that.

On Thu, 07 Jun 2007, David Glasser wrote:

> Reading through the sqlite3 API, it appears that the caller of
> sqlite3_exec is responsible for freeing any error message string that
> is returned.  The following patch does this for the mergeinfo code.
> Since this is my first time working with the mergeinfo code or sqlite3
> in general, I'm posting this for review instead of just committing.
> 
> --dave
> 
> [[[
> * subversion/libsvn_fs_util/mergeinfo-sqlite-index.c
>  (util_sqlite_exec): Don't leak the error string returned from
>   sqlite3_exec.
> ]]]
> 
> -- 
> David Glasser | glasser@mit.edu | http://www.davidglasser.net/

> === subversion/libsvn_fs_util/mergeinfo-sqlite-index.c
> ==================================================================
> --- subversion/libsvn_fs_util/mergeinfo-sqlite-index.c	(revision 148209)
> +++ subversion/libsvn_fs_util/mergeinfo-sqlite-index.c	(local)
> @@ -71,8 +71,12 @@
>                   void *callbackdata)
>  {
>    char *err_msg;
> -  if (sqlite3_exec(db, sql, NULL, NULL, &err_msg) != SQLITE_OK)
> -    return svn_error_create(SVN_ERR_FS_SQLITE_ERROR, NULL, err_msg);
> +  svn_error_t *err;
> +  if (sqlite3_exec(db, sql, NULL, NULL, &err_msg) != SQLITE_OK) {
> +    err = svn_error_create(SVN_ERR_FS_SQLITE_ERROR, NULL, err_msg);
> +    sqlite3_free(err_msg);
> +    return err;
> +  }
>    return SVN_NO_ERROR;
>  }
>