summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/include/util/media-thumb-db.h2
-rwxr-xr-xsrc/util/media-thumb-db.c8
2 files changed, 6 insertions, 4 deletions
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
index b3e3666..fc407fa 100755
--- a/src/include/util/media-thumb-db.h
+++ b/src/include/util/media-thumb-db.h
@@ -26,6 +26,8 @@
#define _MEDIA_THUMB_DB_H_
#define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
+#define SQLITE3_FINALIZE(x) {if (x != NULL) sqlite3_finalize(x); }
+#define SQLITE3_SAFE_FREE(x) {if (x != NULL) {sqlite3_free(x); x = NULL; } }
#define SELECT_THUMB_BY_PATH "SELECT thumbnail_path, width, height FROM media WHERE path='%q';"
#define UPDATE_THUMB_BY_PATH "UPDATE media SET thumbnail_path = '%q' WHERE path='%q';"
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
index e8a999d..a572734 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -64,7 +64,7 @@ int _media_thumb_get_thumb_path_wh_from_db(sqlite3 *handle,
thumb_dbg_slog("Query: %s", query_string);
err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL);
- sqlite3_free(query_string);
+ SQLITE3_SAFE_FREE(query_string);
if (SQLITE_OK != err) {
thumb_err("prepare error [%s]", sqlite3_errmsg(handle));
return MS_MEDIA_ERR_DB_INTERNAL;
@@ -73,7 +73,7 @@ int _media_thumb_get_thumb_path_wh_from_db(sqlite3 *handle,
err = sqlite3_step(stmt);
if (err != SQLITE_ROW) {
thumb_err("end of row [%s]", sqlite3_errmsg(handle));
- sqlite3_finalize(stmt);
+ SQLITE3_FINALIZE(stmt);
return MS_MEDIA_ERR_DB_INTERNAL;
}
@@ -87,7 +87,7 @@ int _media_thumb_get_thumb_path_wh_from_db(sqlite3 *handle,
*height = 0;
}
- sqlite3_finalize(stmt);
+ SQLITE3_FINALIZE(stmt);
return MS_MEDIA_ERR_NONE;
}
@@ -123,7 +123,7 @@ int _media_thumb_update_thumb_path_wh_to_db(const char *origin_path,
thumb_dbg("Query success");
}
- sqlite3_free(query_string);
+ SQLITE3_SAFE_FREE(query_string);
return err;
}