summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2015-07-14 11:07:19 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2015-07-16 10:55:16 (GMT)
commit64959fbc53fd5386a684928617353a9be4890439 (patch)
tree148dade3ac392c7171885063f62b7f230391c8af /src
parent884d011d82489df940044e09b158bb787d3b7037 (diff)
downloadlibmedia-thumbnail-64959fbc53fd5386a684928617353a9be4890439.zip
libmedia-thumbnail-64959fbc53fd5386a684928617353a9be4890439.tar.gz
libmedia-thumbnail-64959fbc53fd5386a684928617353a9be4890439.tar.bz2
Fix memory leak(additional)refs/changes/36/43836/3
Change-Id: I0a2a8cb5ca27bf049498722ca677f3220e1eb7f0 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 53f3ba2..64c4b46 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -659,8 +659,12 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
if (strlen(thumb_path) == 0) {
err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length,uid);
if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_get_hash_name failed - %d\n", err);
- strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
+ char *default_path = _media_thumb_get_default_path(uid);
+ if(default_path) {
+ thumb_err("_media_thumb_get_hash_name failed - %d\n", err);
+ strncpy(thumb_path, default_path, max_length);
+ free(default_path);
+ }
_media_thumb_db_disconnect();
return err;
}
@@ -675,8 +679,12 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
} else if (msg_type == THUMB_REQUEST_ALL_MEDIA) {
err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length,uid);
if (err < 0) {
- thumb_err("_media_thumb_get_hash_name failed - %d\n", err);
- strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
+ char *default_path = _media_thumb_get_default_path(uid);
+ if(default_path) {
+ thumb_err("_media_thumb_get_hash_name failed - %d\n", err);
+ strncpy(thumb_path, default_path, max_length);
+ free(default_path);
+ }
_media_thumb_db_disconnect();
return err;
}
@@ -691,11 +699,15 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
err = _thumbnail_get_data(origin_path, thumb_type, thumb_format, &gdkdata, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, uid);
if (err != MS_MEDIA_ERR_NONE) {
+ char *default_path = _media_thumb_get_default_path(uid);
thumb_err("_thumbnail_get_data failed - %d\n", err);
if ( gdkdata != NULL ){
g_object_unref(gdkdata);
}
- strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
+ if(default_path) {
+ strncpy(thumb_path, default_path, max_length);
+ free(default_path);
+ }
_media_thumb_db_disconnect();
return err;
}
@@ -726,14 +738,18 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
err = _media_thumb_save_to_file_with_gdk(gdkdata, thumb_w, thumb_h, alpha, thumb_path);
if (err < 0) {
+ char *default_path = _media_thumb_get_default_path(uid);
thumb_err("save_to_file_with_gdk failed - %d\n", err);
if ( gdkdata != NULL ){
g_object_unref(gdkdata);
}
- if (msg_type == THUMB_REQUEST_DB_INSERT || msg_type == THUMB_REQUEST_ALL_MEDIA)
- strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
-
+ if (msg_type == THUMB_REQUEST_DB_INSERT || msg_type == THUMB_REQUEST_ALL_MEDIA) {
+ if(default_path) {
+ strncpy(thumb_path, default_path, max_length);
+ free(default_path);
+ }
+ }
_media_thumb_db_disconnect();
return err;
} else {