fix svace issue 57/64457/4
authorJongkyu Koo <jk.koo@samsung.com>
Fri, 1 Apr 2016 08:39:27 +0000 (17:39 +0900)
committerJongkyu Koo <jk.koo@samsung.com>
Mon, 4 Apr 2016 00:08:08 +0000 (17:08 -0700)
Change-Id: Ied3e226e9be388534aad0acc500dbaab5363808d
Signed-off-by: Jongkyu Koo <jk.koo@samsung.com>
common/ctsvc_vcard.c

index 453c953..d7be628 100644 (file)
@@ -1586,18 +1586,20 @@ static inline int __ctsvc_vcard_put_photo(ctsvc_list_s *image_list, char **buf,
                if (CONTACTS_ERROR_NONE != ret) {
                        INFO("__ctsvc_vcard_encode_photo() Fail(%d)", ret);
 
-                       fd = open(data->path, O_RDONLY);
-                       if (fd < 0) {
-                               ERR("System : Open Fail(%d)", errno);
-                               return CONTACTS_ERROR_SYSTEM;
-                       }
-
                        img_buf_size = CTSVC_VCARD_PHOTO_MAX_SIZE * sizeof(unsigned char);
                        image = calloc(1, img_buf_size);
                        if (NULL == image) {
                                ERR("calloc() Fail");
                                return CONTACTS_ERROR_OUT_OF_MEMORY;
                        }
+
+                       fd = open(data->path, O_RDONLY);
+                       if (fd < 0) {
+                               ERR("System : Open Fail(%d)", errno);
+                               free(image);
+                               return CONTACTS_ERROR_SYSTEM;
+                       }
+
                        read_len = 0;
                        while ((ret = read(fd, image+read_len, img_buf_size-read_len))) {
                                if (-1 == ret) {