From 38fd258e5e864122decda471bc394bb2e9cfb9a2 Mon Sep 17 00:00:00 2001 From: Match Grun Date: Sat, 6 Oct 2001 22:58:52 +0000 Subject: [PATCH] fixed segfault when opening dialog, --- src/editldap_basedn.c | 45 ++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/editldap_basedn.c b/src/editldap_basedn.c index 2758d7deb..7b12ec9f4 100644 --- a/src/editldap_basedn.c +++ b/src/editldap_basedn.c @@ -97,10 +97,10 @@ static void edit_ldap_bdn_cancel( GtkWidget *widget, gboolean *cancelled ) { } static void edit_ldap_bdn_list_select( GtkCList *clist, gint row, gint column, GdkEvent *event, gpointer data ) { - gchar **text = NULL; - if( gtk_clist_get_text( clist, row, 0, text ) ) { - if( *text ) { - gtk_entry_set_text(GTK_ENTRY(ldapedit_basedn.basedn_entry), *text ); + gchar *text = NULL; + if( gtk_clist_get_text( clist, row, 0, &text ) ) { + if( text != NULL ) { + gtk_entry_set_text(GTK_ENTRY(ldapedit_basedn.basedn_entry), text ); } } } @@ -122,18 +122,14 @@ static void edit_ldap_bdn_create(void) { GtkWidget *label; GtkWidget *host_label; GtkWidget *port_label; - /* GtkWidget *basedn_label; */ GtkWidget *basedn_list; GtkWidget *vlbox; GtkWidget *lwindow; GtkWidget *basedn_entry; - /* GtkWidget *hlbox; */ GtkWidget *hbbox; GtkWidget *hsep; GtkWidget *ok_btn; GtkWidget *cancel_btn; - /* GtkWidget *check_btn; */ - /* GtkWidget *file_btn; */ GtkWidget *hsbox; GtkWidget *statusbar; gint top; @@ -159,7 +155,7 @@ static void edit_ldap_bdn_create(void) { gtk_table_set_row_spacings(GTK_TABLE(table), 8); gtk_table_set_col_spacings(GTK_TABLE(table), 8); - /* First row */ + // First row top = 0; label = gtk_label_new(_("Hostname")); gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0); @@ -169,7 +165,7 @@ static void edit_ldap_bdn_create(void) { gtk_table_attach(GTK_TABLE(table), host_label, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0); gtk_misc_set_alignment(GTK_MISC(host_label), 0, 0.5); - /* Second row */ + // Second row top = 1; label = gtk_label_new(_("Port")); gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0); @@ -179,7 +175,7 @@ static void edit_ldap_bdn_create(void) { gtk_table_attach(GTK_TABLE(table), port_label, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0); gtk_misc_set_alignment(GTK_MISC(port_label), 0, 0.5); - /* Third row */ + // Third row top = 2; label = gtk_label_new(_("Search Base")); gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0); @@ -188,7 +184,7 @@ static void edit_ldap_bdn_create(void) { basedn_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), basedn_entry, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0); - /* Basedn list */ + // Basedn list vlbox = gtk_vbox_new(FALSE, 8); gtk_box_pack_start(GTK_BOX(vbox), vlbox, TRUE, TRUE, 0); gtk_container_set_border_width( GTK_CONTAINER(vlbox), 8 ); @@ -205,13 +201,13 @@ static void edit_ldap_bdn_create(void) { gtk_clist_set_column_title( GTK_CLIST(basedn_list), 0, _( "Available Search Base(s)" ) ); gtk_clist_set_selection_mode(GTK_CLIST(basedn_list), GTK_SELECTION_BROWSE); - /* Status line */ + // Status line hsbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_end(GTK_BOX(vbox), hsbox, FALSE, FALSE, BORDER_WIDTH); statusbar = gtk_statusbar_new(); gtk_box_pack_start(GTK_BOX(hsbox), statusbar, TRUE, TRUE, BORDER_WIDTH); - /* Button panel */ + // Button panel gtkut_button_set_create(&hbbox, &ok_btn, _("OK"), &cancel_btn, _("Cancel"), NULL, NULL); gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0); @@ -260,23 +256,24 @@ void edit_ldap_bdn_load_data( const gchar *hostName, const gint iPort, const gin gtk_label_set_text(GTK_LABEL(ldapedit_basedn.host_label), hostName); gtk_label_set_text(GTK_LABEL(ldapedit_basedn.port_label), sPort); if( *sHost != '\0' ) { - /* Test connection to server */ + // Test connection to server if( syldap_test_connect_s( sHost, iPort ) ) { - /* Attempt to read base DN */ + // Attempt to read base DN GList *baseDN = syldap_read_basedn_s( sHost, iPort, bindDN, bindPW, tov ); if( baseDN ) { GList *node = baseDN; - gchar *sBase[2]; - sBase[1] = NULL; + gchar *text[2]; + while( node ) { - sBase[0] = g_strdup( node->data ); - gtk_clist_append(GTK_CLIST(ldapedit_basedn.basedn_list), sBase); + text[0] = g_strdup( node->data ); + text[1] = NULL; + gtk_clist_append(GTK_CLIST(ldapedit_basedn.basedn_list), text); node = g_list_next( node ); flgDN = TRUE; } mgu_free_dlist( baseDN ); baseDN = node = NULL; - sBase[0] = NULL; + text[0] = NULL; } ldapedit_basedn_bad_server = FALSE; flgConn = TRUE; @@ -284,7 +281,7 @@ void edit_ldap_bdn_load_data( const gchar *hostName, const gint iPort, const gin } g_free( sHost ); - /* Display appropriate message */ + // Display appropriate message if( flgConn ) { if( ! flgDN ) { sMsg = _( "Could not read Search Base(s) from server - please set manually" ); @@ -310,15 +307,11 @@ gchar *edit_ldap_basedn_selection( const gchar *hostName, const gint port, gchar edit_ldap_bdn_load_data( hostName, port, tov, bindDN, bindPW ); gtk_widget_show(ldapedit_basedn.window); -/* sprintf( sPort, "%d", port ); */ -/* gtk_label_set_text(GTK_LABEL(ldapedit_basedn.host_label), hostName); */ -/* gtk_label_set_text(GTK_LABEL(ldapedit_basedn.port_label), sPort); */ gtk_entry_set_text(GTK_ENTRY(ldapedit_basedn.basedn_entry), baseDN); gtk_main(); gtk_widget_hide(ldapedit_basedn.window); if( ldapedit_basedn_cancelled ) return NULL; -/* if( cancelled == TRUE ) return NULL; */ if( ldapedit_basedn_bad_server ) return NULL; retVal = g_strdup( gtk_editable_get_chars( GTK_EDITABLE(ldapedit_basedn.basedn_entry), 0, -1 ) ); -- 2.25.1