Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Properly handle error in sql_exec().
jlaffaye committed 14 years ago
commit bd00a9f1cd51d2bdeb298ab960167c544dfe3c71
parent 7770c5e
1 file changed +8 -4
modified libpkg/pkgdb.c
@@ -1897,9 +1897,11 @@ sql_exec(sqlite3 *s, const char *sql, ...)
	const char *sql_to_exec;
	char *sqlbuf = NULL;
	char *errmsg;
-
	int ret = EPKG_OK;
+
	int ret = EPKG_FATAL;
+

+
	assert(s != NULL);
+
	assert(sql != NULL);

-
	assert(s != NULL && sql != NULL);
	if (strchr(sql, '%') != NULL) {
		va_start(ap, sql);
		sqlbuf = sqlite3_vmprintf(sql, ap);
@@ -1912,10 +1914,12 @@ sql_exec(sqlite3 *s, const char *sql, ...)
	if (sqlite3_exec(s, sql_to_exec, NULL, NULL, &errmsg) != SQLITE_OK) {
		pkg_emit_error("sqlite: %s", errmsg);
		sqlite3_free(errmsg);
-
		ret = EPKG_FATAL;
-
		return (EPKG_FATAL);
+
		goto cleanup;
	}

+
	ret = EPKG_OK;
+

+
	cleanup:
	if (sqlbuf != NULL)
		free(sqlbuf);