mirror of
				https://github.com/troglobit/editline.git
				synced 2025-11-01 01:01:34 +08:00 
			
		
		
		
	Fix potential memory leak, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
		| @@ -362,16 +362,19 @@ static char *complete(char *token, int *match) | |||||||
|     if (!rl_attempted_completion_over && !words) |     if (!rl_attempted_completion_over && !words) | ||||||
| 	words = rl_completion_matches(word, NULL); | 	words = rl_completion_matches(word, NULL); | ||||||
|  |  | ||||||
|     if (words && words[0]) { |     if (words) { | ||||||
| 	int i = 0; | 	int i = 0; | ||||||
|  |  | ||||||
| 	free(word); | 	free(word); | ||||||
|  | 	word = NULL; | ||||||
|  | 	if (words[0]) | ||||||
| 	    word = strdup(words[0] + len); | 	    word = strdup(words[0] + len); | ||||||
|  |  | ||||||
| 	while (words[i]) | 	while (words[i]) | ||||||
| 	    free(words[i++]); | 	    free(words[i++]); | ||||||
| 	free(words); | 	free(words); | ||||||
|  |  | ||||||
|  | 	if (word) | ||||||
| 	    return word; | 	    return word; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Joachim Nilsson
					Joachim Nilsson