diff options
author | Minje Ahn <minje.ahn@samsung.com> | 2017-07-07 13:42:53 +0900 |
---|---|---|
committer | Minje Ahn <minje.ahn@samsung.com> | 2017-07-07 13:42:53 +0900 |
commit | c5ad1ae3877f3578a820bedbf253c7dd72e8e382 (patch) | |
tree | 05879a283577c7a0fdf66d2636bda58b3fc2439e | |
parent | 8003d8e5e3090490a38eef1387ab6c2587dd5b97 (diff) | |
download | libmedia-thumbnail-c5ad1ae3877f3578a820bedbf253c7dd72e8e382.tar.gz libmedia-thumbnail-c5ad1ae3877f3578a820bedbf253c7dd72e8e382.tar.bz2 libmedia-thumbnail-c5ad1ae3877f3578a820bedbf253c7dd72e8e382.zip |
Modified to check if parameter is null when use sqlite3 api
Change-Id: I452715dee6760ade0203cd21bb12997b93ea3c9e
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rwxr-xr-x | src/include/util/media-thumb-db.h | 2 | ||||
-rwxr-xr-x | src/util/media-thumb-db.c | 8 |
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; } |