mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Fix string handling in get_combo_box_entry_text
Linus' code dropped the const qualifier from the start rating. While fixing this I stared some more at get_combo_box_entry_text and realized that the existing code could potentially change the "old" pointer and then pass it to free(). Tsk-tsk-tsk. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									70f903c457
								
							
						
					
					
						commit
						aab94d07cc
					
				
					 1 changed files with 6 additions and 5 deletions
				
			
		
							
								
								
									
										11
									
								
								info.c
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								info.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -43,7 +43,7 @@ static int text_changed(const char *old, const char *new)
 | 
			
		|||
		(!old && strcmp("",new));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static char *skip_space(char *str)
 | 
			
		||||
static const char *skip_space(const char *str)
 | 
			
		||||
{
 | 
			
		||||
	if (str) {
 | 
			
		||||
		while (isspace(*str))
 | 
			
		||||
| 
						 | 
				
			
			@ -60,13 +60,14 @@ static char *skip_space(char *str)
 | 
			
		|||
 * The "master" string is the string of the current dive - we only consider it
 | 
			
		||||
 * changed if the old string is either empty, or matches that master string.
 | 
			
		||||
 */
 | 
			
		||||
static char *get_combo_box_entry_text(GtkComboBoxEntry *combo_box, char **textp, char *master)
 | 
			
		||||
static char *get_combo_box_entry_text(GtkComboBoxEntry *combo_box, char **textp, const char *master)
 | 
			
		||||
{
 | 
			
		||||
	char *old = *textp;
 | 
			
		||||
	const char *old_text;
 | 
			
		||||
	const gchar *new;
 | 
			
		||||
	GtkEntry *entry;
 | 
			
		||||
 | 
			
		||||
	old = skip_space(old);
 | 
			
		||||
	old_text = skip_space(old);
 | 
			
		||||
	master = skip_space(master);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
| 
						 | 
				
			
			@ -75,8 +76,8 @@ static char *get_combo_box_entry_text(GtkComboBoxEntry *combo_box, char **textp,
 | 
			
		|||
	 * we're editing another dive's info that already had a
 | 
			
		||||
	 * valid value).
 | 
			
		||||
	 */
 | 
			
		||||
	if (master && old)
 | 
			
		||||
		if (strcmp(master, old))
 | 
			
		||||
	if (master && old_text)
 | 
			
		||||
		if (strcmp(master, old_text))
 | 
			
		||||
			return NULL;
 | 
			
		||||
 | 
			
		||||
	entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box)));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue