mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Just use strdup
In commit 272f85bb24 ("Fix silly crash") I indeed fixed the crash, but I
also broke the code. Now a broken userid might end upsaved in the data
file. Oops.
This should be correct now.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
			
			
This commit is contained in:
		
							parent
							
								
									43765d2897
								
							
						
					
					
						commit
						9882bf5ff8
					
				
					 1 changed files with 1 additions and 7 deletions
				
			
		
							
								
								
									
										8
									
								
								dive.c
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								dive.c
									
										
									
									
									
								
							|  | @ -2505,7 +2505,6 @@ timestamp_t get_times() | ||||||
| 	return dive->when; | 	return dive->when; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #define MAX_USERID_SIZE 32 |  | ||||||
| void set_save_userid_local(short value) | void set_save_userid_local(short value) | ||||||
| { | { | ||||||
| 	prefs.save_userid_local = value; | 	prefs.save_userid_local = value; | ||||||
|  | @ -2513,13 +2512,8 @@ void set_save_userid_local(short value) | ||||||
| 
 | 
 | ||||||
| void set_userid(char *rUserId) | void set_userid(char *rUserId) | ||||||
| { | { | ||||||
| 	prefs.userid = (char *)malloc(MAX_USERID_SIZE + 1); | 	prefs.userid = strdup(rUserId); | ||||||
| 	if (prefs.userid && rUserId) { |  | ||||||
| 		strncpy(prefs.userid, rUserId, MAX_USERID_SIZE); |  | ||||||
| 		prefs.userid[MAX_USERID_SIZE] = 0; |  | ||||||
| } | } | ||||||
| } |  | ||||||
| #undef MAX_USERID_SIZE |  | ||||||
| 
 | 
 | ||||||
| int average_depth(struct diveplan *dive) | int average_depth(struct diveplan *dive) | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue