mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	cleanup: use proper size when allocating string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									ef5859437a
								
							
						
					
					
						commit
						a4091189b0
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		|  | @ -2261,7 +2261,7 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct divelog *log) | ||||||
| 	/* Recording the starting battery status to extra data */ | 	/* Recording the starting battery status to extra data */ | ||||||
| 	if (battery_start.volt1) { | 	if (battery_start.volt1) { | ||||||
| 		size_t stringsize = snprintf(NULL, 0, "%dmV (%d%%)", battery_start.volt1, battery_start.percent1) + 1; | 		size_t stringsize = snprintf(NULL, 0, "%dmV (%d%%)", battery_start.volt1, battery_start.percent1) + 1; | ||||||
| 		char *ptr = malloc(size); | 		char *ptr = malloc(stringsize); | ||||||
| 
 | 
 | ||||||
| 		if (ptr) { | 		if (ptr) { | ||||||
| 			snprintf(ptr, stringsize, "%dmV (%d%%)", battery_start.volt1, battery_start.percent1); | 			snprintf(ptr, stringsize, "%dmV (%d%%)", battery_start.volt1, battery_start.percent1); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue