Crash test fix

pull/80/head
Ivan Yartsev 2 years ago
parent e46cd6402d
commit ce7a1df6ba

@ -300,7 +300,7 @@ void on_inspector_jornald_read_async(inspector_window *window){
if (log) if (log)
log++; log++;
if (log){ if (log&&strcmp(log," ")){
char *iden = yon_char_new(identifier); char *iden = yon_char_new(identifier);
identifier=yon_char_divide(iden,strlen(identifier)-(strlen(log)-1)); identifier=yon_char_divide(iden,strlen(identifier)-(strlen(log)-1));
free(iden); free(iden);
@ -743,6 +743,19 @@ void on_logrotate_period_check_toggled(GtkToggleButton *self,logrotate_configure
} }
} }
void on_logrotate_paths_cursor_changed(GtkWidget *self, logrotate_configure_window *window){
GtkTreeModel *model = GTK_TREE_MODEL(window->list);
GtkTreeIter iter;
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){
gtk_widget_set_sensitive(window->LogPathEditButton,1);
gtk_widget_set_sensitive(window->LogPathRemoveButton,1);
} else {
gtk_widget_set_sensitive(window->LogPathEditButton,0);
gtk_widget_set_sensitive(window->LogPathRemoveButton,0);
}
}
void on_logrotate_save(GtkWidget *self, dictionary *dict){ void on_logrotate_save(GtkWidget *self, dictionary *dict){
logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*); logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*);
logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*); logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*);
@ -1157,6 +1170,8 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind
g_signal_connect(G_OBJECT(window->CreateLogButton),"clicked",G_CALLBACK(on_rules_open),window->CreateLogEntry); g_signal_connect(G_OBJECT(window->CreateLogButton),"clicked",G_CALLBACK(on_rules_open),window->CreateLogEntry);
g_signal_connect(G_OBJECT(window->LogPathsTree),"cursor-changed",G_CALLBACK(on_logrotate_paths_cursor_changed),window);
int usize=0; int usize=0;
config_str users = yon_ubl_get_all_users(&usize); config_str users = yon_ubl_get_all_users(&usize);
yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize); yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize);

@ -522,15 +522,18 @@ char *yon_cut(char *source, int size, int startpos)
*/ */
char *yon_char_divide(char *source, int dividepos) char *yon_char_divide(char *source, int dividepos)
{ {
char *cut = malloc(dividepos + 1); if (source){
memset(cut, 0, dividepos + 1); char *cut = malloc(dividepos + 1);
memcpy(cut, source, dividepos); memset(cut, 0, dividepos + 1);
char *left = malloc(strlen(source) - strlen(cut)); memcpy(cut, source, dividepos);
memset(left, 0, strlen(source) - strlen(cut)); char *left = malloc(strlen(source) - strlen(cut));
memcpy(left, source + dividepos + 1, (strlen(source) - dividepos)); memset(left, 0, strlen(source) - strlen(cut));
memset(source, 0, strlen(source)); memcpy(left, source + dividepos + 1, (strlen(source) - dividepos));
memcpy(source, left, strlen(left)); memset(source, 0, strlen(source));
return cut; memcpy(source, left, strlen(left));
return cut;
}
return NULL;
} }
/**yon_char_find_count(char *source, char *find) /**yon_char_find_count(char *source, char *find)

Loading…
Cancel
Save