On Mon, Mar 3, 2008 at 10:16 AM, Igor Tandetnik <[EMAIL PROTECTED]> wrote:
> Jerry Krinock <[EMAIL PROTECTED]> wrote:
> > The Blob Example [1] contains code [2] in which, if sqlite3_prepare()
> > fails, the subsequent call to sqlite3_finalize() is skipped. Is this
> > OK?
>
> If sqlite3_prepare fails, you don't get a valid sqlite3_stmt handle, so
> there's nothing to call sqlite3_finalize on.
sqlite3_finalize() returns SQLITE_OK when you pass NULL. So I'd
expect something like the following to be safe:
sqlite3_stmt *s = NULL;
int rc = sqlite3_prepare(db, zSql, nBytes, &s, NULL);
if( rc!=SQLITE_OK ){
sqlite3_finalize(s);
/* Handle error. */
}
-scott
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users