Commit c53905e563b685be905e6bfe5d31324623373590
1 parent
ac265fb1
Exists in
master
and in
1 other branch
Fixing segfault on host selection dialog.
Showing
1 changed file
with
30 additions
and
23 deletions
Show diff stats
src/dialogs/hostselect.c
| @@ -242,37 +242,44 @@ LIB3270_EXPORT void v3270_host_select_set_session(GtkWidget *w, GtkWidget *sessi | @@ -242,37 +242,44 @@ LIB3270_EXPORT void v3270_host_select_set_session(GtkWidget *w, GtkWidget *sessi | ||
| 242 | V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w); | 242 | V3270HostSelectWidget *widget = GTK_V3270HostSelectWidget(w); |
| 243 | widget->hSession = v3270_get_session(session); | 243 | widget->hSession = v3270_get_session(session); |
| 244 | 244 | ||
| 245 | - g_autofree gchar * url = g_strdup(lib3270_get_url(widget->hSession)); | ||
| 246 | - debug("URL=[%s]",url); | 245 | + const gchar * u = lib3270_get_url(widget->hSession); |
| 247 | 246 | ||
| 248 | - gchar *hostname = strstr(url,"://"); | ||
| 249 | - if(!hostname) | ||
| 250 | - { | ||
| 251 | - g_message("Invalid URL: \"%s\" (no scheme)",url); | ||
| 252 | - } | ||
| 253 | - else | ||
| 254 | - { | ||
| 255 | - hostname += 3; | 247 | + if(u) |
| 248 | + { | ||
| 256 | 249 | ||
| 257 | - gchar *srvcname = strchr(hostname,':'); | 250 | + g_autofree gchar * url = g_strdup(u); |
| 251 | + debug("URL=[%s]",url); | ||
| 258 | 252 | ||
| 259 | - if(srvcname) | ||
| 260 | - { | ||
| 261 | - *(srvcname++) = 0; | ||
| 262 | - } | ||
| 263 | - else | ||
| 264 | - { | ||
| 265 | - srvcname = "telnet"; | ||
| 266 | - } | 253 | + gchar *hostname = strstr(url,"://"); |
| 254 | + if(!hostname) | ||
| 255 | + { | ||
| 256 | + g_message("Invalid URL: \"%s\" (no scheme)",url); | ||
| 257 | + } | ||
| 258 | + else | ||
| 259 | + { | ||
| 260 | + hostname += 3; | ||
| 267 | 261 | ||
| 268 | - gtk_entry_set_text(widget->input.entry[ENTRY_HOSTNAME],hostname); | ||
| 269 | - gtk_entry_set_text(widget->input.entry[ENTRY_SRVCNAME],srvcname); | 262 | + gchar *srvcname = strchr(hostname,':'); |
| 270 | 263 | ||
| 271 | - } | 264 | + if(srvcname) |
| 265 | + { | ||
| 266 | + *(srvcname++) = 0; | ||
| 267 | + } | ||
| 268 | + else | ||
| 269 | + { | ||
| 270 | + srvcname = "telnet"; | ||
| 271 | + } | ||
| 272 | + | ||
| 273 | + gtk_entry_set_text(widget->input.entry[ENTRY_HOSTNAME],hostname); | ||
| 274 | + gtk_entry_set_text(widget->input.entry[ENTRY_SRVCNAME],srvcname); | ||
| 275 | + | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + } | ||
| 272 | 279 | ||
| 273 | LIB3270_HOST_TYPE type = lib3270_get_host_type(widget->hSession); | 280 | LIB3270_HOST_TYPE type = lib3270_get_host_type(widget->hSession); |
| 274 | 281 | ||
| 275 | - gtk_toggle_button_set_active(widget->input.ssl,g_str_has_prefix(url,"tn3270s://") != 0); | 282 | + gtk_toggle_button_set_active(widget->input.ssl,lib3270_get_secure_host(widget->hSession) != 0); |
| 276 | 283 | ||
| 277 | // Set host type | 284 | // Set host type |
| 278 | { | 285 | { |