mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Teach copy_string to return NULL on empty string
In subsurface we store no value as a NULL pointer everywhere, but sometimes some structures returns a empty field as a empty string. This teaches our helper copy_string to return NULL if you try to copy a empty string. This fixes a bug where we store buddy and divemaster in git as empty strings if they passed via MainTab::saveTaggedStrings(). Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									65aab8199f
								
							
						
					
					
						commit
						5a61c81cc2
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		
							
								
								
									
										2
									
								
								dive.h
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								dive.h
									
										
									
									
									
								
							|  | @ -32,7 +32,7 @@ static inline int same_string(const char *a, const char *b) | ||||||
| 
 | 
 | ||||||
| static inline char *copy_string(const char *s) | static inline char *copy_string(const char *s) | ||||||
| { | { | ||||||
| 	return s ? strdup(s) : NULL; | 	return (s && *s) ? strdup(s) : NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #include <libxml/tree.h> | #include <libxml/tree.h> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue