Fixed strstr crash 20/57820/1
authorpolu.sandeep <polu.sandeep@samsung.com>
Mon, 25 Jan 2016 04:14:20 +0000 (13:14 +0900)
committerpolu.sandeep <polu.sandeep@samsung.com>
Mon, 25 Jan 2016 04:14:20 +0000 (13:14 +0900)
Change-Id: I4f7705086e8adebe6e62cf9ec5de23c47305cc7b

TelegramTizen/src/telegramtizen.c
TelegramTizen/src/tg_messaging_view.c
TelegramTizen/src/tg_settings_view.c
tg-engine-service/tg_engine/tg_engine.c

index 50b9818..f5d0286 100644 (file)
@@ -455,7 +455,7 @@ void load_main_list_data(appdata_s *ad)
                                                                        char *phone_num = NULL;
                                                                        get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
-                                                                       if (!first_name || strstr(first_name ,"null") != 0) {
+                                                                       if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                                                                first_name = NULL;
                                                                        }
 
@@ -463,7 +463,7 @@ void load_main_list_data(appdata_s *ad)
                                                                                first_name = phone_num;
                                                                        }
 
-                                                                       if (!last_name || strstr(last_name ,"null") != 0) {
+                                                                       if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                                                                last_name = "";
                                                                        }
                                                                        user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -479,7 +479,7 @@ void load_main_list_data(appdata_s *ad)
                                                                char *phone_num = NULL;
                                                                get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
-                                                               if (!first_name || strstr(first_name ,"null") != 0) {
+                                                               if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                                                        first_name = NULL;
                                                                }
 
@@ -487,7 +487,7 @@ void load_main_list_data(appdata_s *ad)
                                                                        first_name = phone_num;
                                                                }
 
-                                                               if (!last_name || strstr(last_name ,"null") != 0) {
+                                                               if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                                                        last_name = "";
                                                                }
                                                                user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -557,7 +557,7 @@ void load_main_list_data(appdata_s *ad)
                                                                char *phone_num = NULL;
                                                                get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
-                                                               if (!first_name || strstr(first_name ,"null") != 0) {
+                                                               if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                                                        first_name = NULL;
                                                                }
 
@@ -565,7 +565,7 @@ void load_main_list_data(appdata_s *ad)
                                                                        first_name = phone_num;
                                                                }
 
-                                                               if (!last_name || strstr(last_name ,"null") != 0) {
+                                                               if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                                                        last_name = "";
                                                                }
                                                                user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -2365,7 +2365,7 @@ static int on_media_message_download_completed(appdata_s *app, bundle *const rec
 
        //file_name == "failed_to_load"
 
-       if (strstr(file_name, "failed_to_load") != NULL) {
+       if (file_name && strstr(file_name, "failed_to_load") != NULL) {
                // download failed.
                show_toast(app, "media download failed.");
        }
@@ -3083,7 +3083,7 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad,  peer_with_pic_s *item)
                                                                char *phone_num = NULL;
                                                                get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
-                                                               if (!first_name || strstr(first_name ,"null") != 0) {
+                                                               if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                                                        first_name = NULL;
                                                                }
 
@@ -3091,7 +3091,7 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad,  peer_with_pic_s *item)
                                                                        first_name = phone_num;
                                                                }
 
-                                                               if (!last_name || strstr(last_name ,"null") != 0) {
+                                                               if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                                                        last_name = "";
                                                                }
                                                                user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -3107,7 +3107,7 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad,  peer_with_pic_s *item)
                                                        char *phone_num = NULL;
                                                        get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
-                                                       if (!first_name || strstr(first_name ,"null") != 0) {
+                                                       if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                                                first_name = NULL;
                                                        }
 
@@ -3119,7 +3119,7 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad,  peer_with_pic_s *item)
                                                                first_name = "";
                                                        }
 
-                                                       if (!last_name || strstr(last_name ,"null") != 0) {
+                                                       if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                                                last_name = "";
                                                        }
                                                        user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -3196,7 +3196,7 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad,  peer_with_pic_s *item)
                                                        char *phone_num = NULL;
                                                        get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
-                                                       if (!first_name || strstr(first_name ,"null") != 0) {
+                                                       if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                                                first_name = NULL;
                                                        }
 
@@ -3206,7 +3206,7 @@ tg_main_list_item_s* get_latest_item(appdata_s *ad,  peer_with_pic_s *item)
                                                        if (!first_name) {
                                                                first_name = "";
                                                        }
-                                                       if (!last_name || strstr(last_name ,"null") != 0) {
+                                                       if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                                                last_name = "";
                                                        }
                                                        user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -3426,7 +3426,7 @@ void app_nf_back_cb(void *data, Evas_Object *obj, void *event_info)
                                                                                                char *phone_num = NULL;
                                                                                                get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
-                                                                                               if (!first_name || strstr(first_name ,"null") != 0) {
+                                                                                               if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                                                                                        first_name = NULL;
                                                                                                }
 
@@ -3434,7 +3434,7 @@ void app_nf_back_cb(void *data, Evas_Object *obj, void *event_info)
                                                                                                        first_name = phone_num;
                                                                                                }
 
-                                                                                               if (!last_name || strstr(last_name ,"null") != 0) {
+                                                                                               if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                                                                                        last_name = "";
                                                                                                }
                                                                                                user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -3450,7 +3450,7 @@ void app_nf_back_cb(void *data, Evas_Object *obj, void *event_info)
                                                                                        char *phone_num = NULL;
                                                                                        get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
-                                                                                       if (!first_name || strstr(first_name ,"null") != 0) {
+                                                                                       if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                                                                                first_name = NULL;
                                                                                        }
 
@@ -3458,7 +3458,7 @@ void app_nf_back_cb(void *data, Evas_Object *obj, void *event_info)
                                                                                                first_name = phone_num;
                                                                                        }
 
-                                                                                       if (!last_name || strstr(last_name ,"null") != 0) {
+                                                                                       if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                                                                                last_name = "";
                                                                                        }
                                                                                        user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
@@ -3528,7 +3528,7 @@ void app_nf_back_cb(void *data, Evas_Object *obj, void *event_info)
                                                                                        char *phone_num = NULL;
                                                                                        get_buddy_contact_details_from_db(peer_info->peer_id, &first_name, &last_name, &phone_num);
 
-                                                                                       if (!first_name || strstr(first_name ,"null") != 0) {
+                                                                                       if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                                                                                first_name = NULL;
                                                                                        }
 
@@ -3536,7 +3536,7 @@ void app_nf_back_cb(void *data, Evas_Object *obj, void *event_info)
                                                                                                first_name = phone_num;
                                                                                        }
 
-                                                                                       if (!last_name || strstr(last_name ,"null") != 0) {
+                                                                                       if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                                                                                last_name = "";
                                                                                        }
                                                                                        user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
index e6228b2..aba7d55 100644 (file)
@@ -523,9 +523,9 @@ void on_sent_media_item_clicked(void* data, Evas_Object* layout, void* event_inf
                        return;
                }
                app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW);
-               if (strstr(media_type_str, "video") != NULL) {
+               if (media_type_str && strstr(media_type_str, "video") != NULL) {
                        app_control_set_mime(app_control,"video/*");
-               } else if (strstr(media_type_str, "audio") != NULL) {
+               } else if (media_type_str && strstr(media_type_str, "audio") != NULL) {
                        app_control_set_mime(app_control,"audio/*");
                } else {
                        app_control_set_mime(app_control,"image/*");
@@ -826,7 +826,7 @@ static void on_message_play_pause_clicked(void *data, Evas_Object *obj, void *ev
        appdata_s * ad = evas_object_data_get(data, "app_data");
        char *audio_file = evas_object_data_get(data, "audio_file_path");
        char *media_id = evas_object_data_get(data, "media_id");
-       if (!audio_file  || strlen(audio_file) <= 0 || strstr(audio_file, "_null_") != NULL) {
+       if (!audio_file  || strlen(audio_file) <= 0 || (audio_file && strstr(audio_file, "_null_")) != NULL) {
                //there is no file. download it.
                Evas_Object *progressbar = evas_object_data_get(data, "progress_control");
                Eina_Bool is_download_in_progress = (Eina_Bool)evas_object_data_get(progressbar, "is_download_in_progress");
@@ -1082,12 +1082,12 @@ static Evas_Object * item_provider(void *data, Evas_Object *entry, const char *i
                        if (msg->media_type == tgl_message_media_document) {
                                media_msg = get_media_details_from_db(atoll(msg->media_id));
 
-                               if (media_msg && strstr(media_msg->doc_type, "video") != NULL) {
+                               if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "video") != NULL) {
                                        if (img_path == NULL || strlen(img_path) == 0) {
                                                img_path = strdup(ui_utils_get_resource(TG_VIDEO_ICON));
                                        }
                                }
-                               if (media_msg && strstr(media_msg->doc_type, "audio") != NULL) {
+                               if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "audio") != NULL) {
                                        if (img_path) {
                                                free(img_path);
                                                img_path = NULL;
@@ -1095,7 +1095,7 @@ static Evas_Object * item_provider(void *data, Evas_Object *entry, const char *i
                                        img_path = strdup(ui_utils_get_resource(TG_AUDIO_ICON));
                                }
                                char* media_file = get_media_path_from_db(atoll(msg->media_id));
-                               if (!media_file || !strcmp(media_file, "_null_") || strlen(media_file) <= 0 ||  access(media_file, F_OK) == -1) {
+                               if (!media_file || (media_file && !strcmp(media_file, "_null_")) || (media_file && strlen(media_file) <= 0) ||  (media_file && access(media_file, F_OK) == -1)) {
                                        is_blur_image = EINA_TRUE;
                                }
 
@@ -1106,7 +1106,7 @@ static Evas_Object * item_provider(void *data, Evas_Object *entry, const char *i
 
                        }
 
-                       if (media_msg && strstr(media_msg->doc_type, "audio") != NULL) {
+                       if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "audio") != NULL) {
 
                                evas_object_data_set(chat_scroller, "parent_obj", (void*)entry);
                                item_to_display = get_audio_layout_with_play(chat_scroller);
@@ -1118,7 +1118,7 @@ static Evas_Object * item_provider(void *data, Evas_Object *entry, const char *i
                                        //item_to_display = get_image_from_path(img_path, entry);
 
                                } else {
-                                       if (media_msg && strstr(media_msg->doc_type, "video") != NULL) {
+                                       if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "video") != NULL) {
 
                                                item_to_display = get_media_layout_with_play(img_path, entry, EINA_TRUE);
 
@@ -1137,12 +1137,12 @@ static Evas_Object * item_provider(void *data, Evas_Object *entry, const char *i
                                                evas_object_data_set(entry, "image_object", (void*)item_to_display);
 
                                        } else {
-                                               if (media_msg && strstr(media_msg->doc_type, "video") != NULL) {
+                                               if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "video") != NULL) {
 
                                                        item_to_display = get_media_layout_with_play(img_path, entry, EINA_TRUE);
 
                                                } else {
-                                                       if (strstr(media_msg->mime_type, "webp") != NULL) {
+                                                       if (media_msg && media_msg->mime_type && strstr(media_msg->mime_type, "webp") != NULL) {
                                                                evas_object_data_set(entry, "image_object", (void*)item_to_display);
                                                        } else {
                                                                evas_object_data_set(entry, "image_object", (void*)item_to_display);
@@ -1166,7 +1166,7 @@ static Evas_Object * item_provider(void *data, Evas_Object *entry, const char *i
                                        if (msg->media_type == tgl_message_media_photo) {
                                                img_item = get_image_from_path(img_path, entry);
                                        } else {
-                                               if ((media_msg && strstr(media_msg->doc_type, "video") != NULL )|| (media_msg && strstr(media_msg->doc_type, "audio") != NULL)) {
+                                               if ((media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "video") != NULL )|| (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "audio") != NULL)) {
                                                        img_item = get_media_layout_with_play(img_path, entry, EINA_FALSE);
                                                } else {
                                                        img_item = get_image_from_path(img_path, entry);
@@ -1178,9 +1178,9 @@ static Evas_Object * item_provider(void *data, Evas_Object *entry, const char *i
                                        if (msg->media_type == tgl_message_media_photo) {
                                                media_size = get_image_size(atoll(msg->media_id));
                                        } else {
-                                               if (media_msg && strstr(media_msg->doc_type, "video") != NULL) {
+                                               if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "video") != NULL) {
                                                        media_size = get_media_size_from_db(atoll(msg->media_id));
-                                               } else if (media_msg && strstr(media_msg->doc_type, "audio") != NULL) {
+                                               } else if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "audio") != NULL) {
                                                        media_size = get_media_size_from_db(atoll(msg->media_id));
                                                } else {
                                                        media_size = get_media_size_from_db(atoll(msg->media_id));
@@ -1238,12 +1238,12 @@ static Evas_Object * item_provider(void *data, Evas_Object *entry, const char *i
                } else if (msg->media_type == tgl_message_media_geo) {
                        evas_object_data_set(entry, "media_type", (void*)strdup("location"));
                } else {
-                       if (media_msg && strstr(media_msg->doc_type, "video") != NULL) {
+                       if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "video") != NULL) {
                                evas_object_data_set(entry, "media_type", (void*)strdup("video"));
-                       } else if (media_msg && strstr(media_msg->doc_type, "audio") != NULL) {
+                       } else if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "audio") != NULL) {
                                evas_object_data_set(entry, "media_type", (void*)strdup("audio"));
                        } else {
-                               if (strstr(media_msg->mime_type, "webp") != NULL) {
+                               if (media_msg && media_msg->mime_type && strstr(media_msg->mime_type, "webp") != NULL) {
                                        evas_object_data_set(entry, "media_type", (void*)strdup("image"));
                                } else {
                                        evas_object_data_set(entry, "media_type", (void*)strdup("animated_gif"));
@@ -1253,7 +1253,7 @@ static Evas_Object * item_provider(void *data, Evas_Object *entry, const char *i
 
                evas_object_data_set(entry, "media_id", (void*)strdup(msg->media_id));
                if (item_to_display) {
-                       if (media_msg && strstr(media_msg->doc_type, "audio") != NULL) {
+                       if (media_msg && media_msg->doc_type && strstr(media_msg->doc_type, "audio") != NULL) {
                                layout = item_to_display;
                        } else {
                                char edj_path[PATH_MAX] = {0, };
@@ -1318,7 +1318,7 @@ static void _create_image_item(tg_message_s *msg, Evas_Object *entry, char *imag
 {
        char* img_path = NULL;
        img_path = get_video_thumb_path_from_db(atoll(msg->media_id));
-       if (img_path == NULL || strlen(img_path) == 0 || strstr(img_path, "_null_") != NULL) {
+       if (img_path == NULL || (img_path && strlen(img_path) == 0) || (img_path && strstr(img_path, "_null_") != NULL)) {
                img_path = get_media_path_from_db(atoll(msg->media_id));
                if( access (img_path, F_OK) == -1 ) {
                        img_path = NULL;
@@ -1514,14 +1514,14 @@ Evas_Object *on_message_item_content_get_cb(void *data, Evas_Object *obj, const
                                }
                                if (msg->out) {
                                        if (media_msg) {
-                                               if (strstr(media_msg->doc_type, "audio") != NULL) {
+                                               if (media_msg->doc_type && strstr(media_msg->doc_type, "audio") != NULL) {
                                                        if (ad->target_direction == TELEGRAM_TARGET_DIRECTION_PORTRAIT || ad->target_direction == TELEGRAM_TARGET_DIRECTION_PORTRAIT_INVERSE) {
                                                                eina_strbuf_append(buf, "<item size=318x100 vsize=full hsize=full href=itemprovider></item>");
                                                        } else {
                                                                eina_strbuf_append(buf, "<item size=318x100 vsize=full hsize=full href=itemprovider></item>");
                                                        }
 
-                                               } else if (strstr(media_msg->doc_type, "video") != NULL) {
+                                               } else if (media_msg->doc_type && strstr(media_msg->doc_type, "video") != NULL) {
                                                        eina_strbuf_append(buf, "<item size=318x200 vsize=full hsize=full href=itemprovider></item>");
                                                } else {
                                                        char image[256]={0,};
@@ -1531,9 +1531,9 @@ Evas_Object *on_message_item_content_get_cb(void *data, Evas_Object *obj, const
                                        }
                                } else {
                                        if (media_msg) {
-                                               if (strstr(media_msg->doc_type, "audio") != NULL) {
+                                               if (media_msg->doc_type && strstr(media_msg->doc_type, "audio") != NULL) {
                                                        eina_strbuf_append(buf, "<item size=318x100 vsize=full hsize=full href=itemprovider></item>");
-                                               } else if (strstr(media_msg->doc_type, "video") != NULL) {
+                                               } else if (media_msg->doc_type && strstr(media_msg->doc_type, "video") != NULL) {
                                                        eina_strbuf_append(buf, "<item size=318x200 vsize=full hsize=full href=itemprovider></item>");
                                                } else {
                                                        char image[256]={0,};
@@ -1776,12 +1776,12 @@ void on_media_download_completed(appdata_s* ad, int buddy_id, long long media_id
                                        long long lmedia_id = atoll(media_id_str);
 
                                        if (media_id == lmedia_id) {
-                                               if (img_item || (strstr(media_type_str, "audio") != NULL)) {
+                                               if (img_item || (media_type_str && strstr(media_type_str, "audio") != NULL)) {
 
 
-                                                       if (strstr(file_path, "failed_to_load") != NULL) {
+                                                       if (file_path && strstr(file_path, "failed_to_load") != NULL) {
 
-                                                               if ((strstr(media_type_str, "audio") != NULL)) {
+                                                               if (media_type_str && (strstr(media_type_str, "audio") != NULL)) {
                                                                        Evas_Object *play_pause_icon = evas_object_data_get(entry, "play_pause_icon");
                                                                        Evas_Object *progressbar = evas_object_data_get(entry, "progress_bar");
                                                                        evas_object_data_set(progressbar, "is_download_in_progress", EINA_FALSE);
@@ -1808,7 +1808,7 @@ void on_media_download_completed(appdata_s* ad, int buddy_id, long long media_id
 
                                                        } else {
 
-                                                               if ((strstr(media_type_str, "audio") != NULL)) {
+                                                               if (media_type_str && (strstr(media_type_str, "audio") != NULL)) {
                                                                        Evas_Object *play_pause_icon = evas_object_data_get(entry, "play_pause_icon");
                                                                        Evas_Object *progressbar = evas_object_data_get(entry, "progress_bar");
                                                                        evas_object_data_set(progressbar, "is_download_in_progress", EINA_FALSE);
@@ -1838,11 +1838,11 @@ void on_media_download_completed(appdata_s* ad, int buddy_id, long long media_id
                                                                        evas_object_del(size_btn);
                                                                }
 
-                                                               if ((strstr(media_type_str, "video") != NULL)) {
+                                                               if (media_type_str && (strstr(media_type_str, "video") != NULL)) {
                                                                        Evas_Object* play_img = get_video_paly_icon(img_item);
                                                                        //Evas_Object* play_img = get_image_from_path(ui_utils_get_resource(MEDIA_PLAY_ICON), img_item);
                                                                        elm_object_part_content_set(img_item, "swallow.play_btn", play_img);
-                                                               } else if (strstr(media_type_str, "image") != NULL) {
+                                                               } else if (media_type_str && strstr(media_type_str, "image") != NULL) {
 
                                                                        img_item = get_image_from_path(file_path, entry);
                                                                        int w, h, entry_h;
@@ -1856,7 +1856,7 @@ void on_media_download_completed(appdata_s* ad, int buddy_id, long long media_id
                                                                        elm_entry_entry_set(entry, eina_strbuf_string_get(buf));
                                                                        eina_strbuf_free(buf);
 
-                                                               } else if (strstr(media_type_str, "animated_gif") != NULL) {
+                                                               } else if (media_type_str && strstr(media_type_str, "animated_gif") != NULL) {
 
                                                                        int msg_id = (int) evas_object_data_get(entry, "message_id");
                                                                        char key[256] = {0, };
@@ -3669,6 +3669,7 @@ void launch_messaging_view_cb(appdata_s* ad, int user_id)
                char *phone_num = get_buddy_phone_num_from_id(sel_item->use_data->peer_id);
 
                if (phone_num == NULL || (phone_num && strcmp(phone_num, "+") == 0)) {
+#if 0
                        char *user_name = NULL;
                        char *first_name = NULL;
                        char *last_name = NULL;
@@ -3692,7 +3693,12 @@ void launch_messaging_view_cb(appdata_s* ad, int user_id)
                        strcat(user_name, last_name);
                        snprintf(temp_name, 512, "%s", user_name);
                        free(user_name);
-
+#endif
+                       if (sel_item->use_data->print_name) {
+                               snprintf(temp_name, 512, "%s", sel_item->use_data->print_name);
+                       } else {
+                               snprintf(temp_name, 512, "%s", "unknown");
+                       }
                } else {
                        snprintf(temp_name, 512, "%s", get_buddy_phone_num_from_id(sel_item->use_data->peer_id));
                }
index 5b64fb0..cb3c381 100644 (file)
@@ -685,7 +685,7 @@ char* _text_requested_cb(void *data, Evas_Object *obj, const char *part)
                                last_name = ad->current_user_data->last_name;
 
 
-                               if (!first_name || strstr(first_name ,"null") != 0) {
+                               if (!first_name || (first_name && strstr(first_name ,"null") != 0)) {
                                        first_name = NULL;
                                }
 
@@ -693,7 +693,7 @@ char* _text_requested_cb(void *data, Evas_Object *obj, const char *part)
                                        first_name = "";
                                }
 
-                               if (!last_name || strstr(last_name ,"null") != 0) {
+                               if (!last_name || (last_name && strstr(last_name ,"null") != 0)) {
                                        last_name = "";
                                }
                                user_name = (char*)malloc(strlen(first_name) + strlen(" ") + strlen(last_name) + 1);
index 20a227c..64823e9 100644 (file)
@@ -3132,11 +3132,11 @@ void media_download_request(tg_engine_data_s *tg_data, int buddy_id, long long m
                        if (!(img_details->mime_type) || strlen(img_details->mime_type) <= 0) {
 
                                if (img_details->doc_type && strlen(img_details->doc_type) > 0) {
-                                       if (strstr(img_details->doc_type, "video") != NULL) {
+                                       if (img_details->doc_type && strstr(img_details->doc_type, "video") != NULL) {
                                                doc_prop->mime_type = strdup("video/mp4");
-                                       } else if (strstr(img_details->doc_type, "audio") != NULL) {
+                                       } else if (img_details->doc_type && strstr(img_details->doc_type, "audio") != NULL) {
                                                doc_prop->mime_type = strdup("audio/wav");
-                                       } else if (strstr(img_details->doc_type, "image/gif") != NULL) {
+                                       } else if (img_details->doc_type && strstr(img_details->doc_type, "image/gif") != NULL) {
                                                doc_prop->mime_type = strdup("image/gif");
                                        }
                                }
@@ -3144,11 +3144,11 @@ void media_download_request(tg_engine_data_s *tg_data, int buddy_id, long long m
                                doc_prop->mime_type = img_details->mime_type;
                        }
 
-                       if (strstr(img_details->doc_type, "video") != NULL) {
+                       if (strstr(img_details->doc_type && img_details->doc_type, "video") != NULL) {
                                doc_prop->flags =  FLAG_DOCUMENT_VIDEO;
-                       } else if (strstr(img_details->doc_type, "audio") != NULL) {
+                       } else if (img_details->doc_type && strstr(img_details->doc_type, "audio") != NULL) {
                                doc_prop->flags =  FLAG_DOCUMENT_AUDIO;
-                       } else if (strstr(img_details->doc_type, "image") != NULL) {
+                       } else if (img_details->doc_type && strstr(img_details->doc_type, "image") != NULL) {
                                doc_prop->flags =  FLAG_DOCUMENT_ANIMATED;
                        }
 
@@ -3675,7 +3675,7 @@ void send_media_to_buddy(int buddy_id, int message_id, int media_id, int msg_typ
                                        mime_type_get_mime_type(extn, &mime_type);
                                }
 
-                               if (strstr(mime_type, "video") != NULL) {
+                               if (mime_type && strstr(mime_type, "video") != NULL) {
 
                                        char* thumb_path = get_video_thumb_path_from_db(media_id);
                                        tgl_do_send_video(s_info.TLS, -2, msg->to_id, file_path, thumb_path, &on_message_sent_to_buddy, (void*) (msg));
@@ -3683,7 +3683,7 @@ void send_media_to_buddy(int buddy_id, int message_id, int media_id, int msg_typ
                                                free(thumb_path);
                                                thumb_path = NULL;
                                        }
-                               } else if (strstr(mime_type, "audio") != NULL) {
+                               } else if (mime_type && strstr(mime_type, "audio") != NULL) {
                                        tgl_do_send_audio(s_info.TLS, msg->to_id, file_path, &on_message_sent_to_buddy, (void*) (msg));
                                } else {
 
@@ -3723,7 +3723,7 @@ void send_media_to_buddy(int buddy_id, int message_id, int media_id, int msg_typ
                                        mime_type_get_mime_type(extn, &mime_type);
                                }
 
-                               if (strstr(mime_type, "video") != NULL) {
+                               if (mime_type && strstr(mime_type, "video") != NULL) {
 
                                        char* thumb_path = get_video_thumb_path_from_db(media_id);
                                        tgl_do_send_video(s_info.TLS, -2, msg->to_id, file_path, thumb_path, &on_message_sent_to_buddy, (void*) (msg));
@@ -3731,7 +3731,7 @@ void send_media_to_buddy(int buddy_id, int message_id, int media_id, int msg_typ
                                                free(thumb_path);
                                                thumb_path = NULL;
                                        }
-                               } else if (strstr(mime_type, "audio") != NULL) {
+                               } else if (mime_type && strstr(mime_type, "audio") != NULL) {
                                        tgl_do_send_audio(s_info.TLS, msg->to_id, file_path, &on_message_sent_to_buddy, (void*) (msg));
                                } else {