[db_upgrade] Fix memory leak in error case

db_upgrade.c:72:7: warning: Potential memory leak
This commit is contained in:
chme 2018-12-17 08:35:43 +01:00 committed by ejurgensen
parent 21ce281cd1
commit b7f3e71f7e
1 changed files with 11 additions and 4 deletions

View File

@ -72,7 +72,9 @@ db_drop_indices(sqlite3 *hdl)
DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(hdl));
sqlite3_finalize(stmt);
return -1;
ret = -1;
goto out;
}
sqlite3_finalize(stmt);
@ -80,7 +82,6 @@ db_drop_indices(sqlite3 *hdl)
for (i = 0; i < n; i++)
{
query = sqlite3_mprintf(Q_TMPL, index[i]);
free(index[i]);
DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query);
@ -90,13 +91,19 @@ db_drop_indices(sqlite3 *hdl)
DPRINTF(E_LOG, L_DB, "DB error while running '%s': %s\n", query, errmsg);
sqlite3_free(errmsg);
return -1;
sqlite3_free(query);
ret = -1;
goto out;
}
sqlite3_free(query);
}
return 0;
out:
for (i = 0; i < n; i++)
free(index[i]);
return ret;
#undef Q_TMPL
#undef Q_INDEX
}