compare_string_array: code shrink
Code shrink and prevention of possible out of bounds access. function old new delta nth_string 36 26 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-10) Total: -10 bytes text data bss dec hex filename 981342 16915 1872 1000129 f42c1 busybox_old 981332 16915 1872 1000119 f42b7 busybox_unstripped Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
		
				
					committed by
					
						 Denys Vlasenko
						Denys Vlasenko
					
				
			
			
				
	
			
			
			
						parent
						
							ac79db6a3b
						
					
				
				
					commit
					c9fc15359e
				
			| @@ -117,8 +117,11 @@ int FAST_FUNC index_in_substrings(const char *strings, const char *key) | ||||
| const char* FAST_FUNC nth_string(const char *strings, int n) | ||||
| { | ||||
| 	while (n) { | ||||
| 		n--; | ||||
| 		strings += strlen(strings) + 1; | ||||
| 		if (*strings++ == '\0') { | ||||
| 			if (*strings == '\0') /* reached end of strings */ | ||||
| 				break; | ||||
| 			n--; | ||||
| 		} | ||||
| 	} | ||||
| 	return strings; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user