comparison gui/dialog/url.c @ 36085:d3e8f4f71514

Check return value to avoid segmentation fault.
author ib
date Mon, 29 Apr 2013 11:36:53 +0000
parents 64825e4a3fed
children 6e0e3d0a36c0
comparison
equal deleted inserted replaced
36084:64825e4a3fed 36085:d3e8f4f71514
51 if (str) { 51 if (str) {
52 if (!strstr(str, "://")) { 52 if (!strstr(str, "://")) {
53 char *tmp; 53 char *tmp;
54 54
55 tmp = malloc(strlen(str) + 8); 55 tmp = malloc(strlen(str) + 8);
56 sprintf(tmp, "http://%s", str); 56
57 if (tmp)
58 sprintf(tmp, "http://%s", str);
59
57 free(str); 60 free(str);
58 str = tmp; 61 str = tmp;
59 } 62 }
60 63
64 if (str) {
61 item = calloc(1, sizeof(urlItem)); 65 item = calloc(1, sizeof(urlItem));
62 item->url = gstrdup(str); 66 item->url = gstrdup(str);
63 listMgr(URLLIST_ITEM_ADD, item); 67 listMgr(URLLIST_ITEM_ADD, item);
64 68
65 uiSetFile(NULL, str, STREAMTYPE_STREAM); 69 uiSetFile(NULL, str, STREAMTYPE_STREAM);
66 listMgr(PLAYLIST_DELETE, 0); 70 listMgr(PLAYLIST_DELETE, 0);
67 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND); 71 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND);
68 guiInfo.NewPlay = GUI_FILE_NEW; 72 guiInfo.NewPlay = GUI_FILE_NEW;
69 uiEvent(evPlay, 0); 73 uiEvent(evPlay, 0);
74 }
70 } 75 }
71 } 76 }
72 77
73 gtk_widget_destroy(URLDialog); 78 gtk_widget_destroy(URLDialog);
74 } 79 }