Fix memory leak and print a warning on invalid regex
This will minimize the already low memory usage of sent.
This commit is contained in:
		
							
								
								
									
										6
									
								
								sent.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								sent.c
									
									
									
									
									
								
							| @ -185,12 +185,16 @@ ffload(Slide *s) | |||||||
|  |  | ||||||
| 	for (i = 0; i < LEN(filters); i++) { | 	for (i = 0; i < LEN(filters); i++) { | ||||||
| 		if (regcomp(®ex, filters[i].regex, | 		if (regcomp(®ex, filters[i].regex, | ||||||
| 		            REG_NOSUB | REG_EXTENDED | REG_ICASE)) | 		            REG_NOSUB | REG_EXTENDED | REG_ICASE)) { | ||||||
|  | 			fprintf(stderr, "sent: Invalid regex '%s'\n", filters[i].regex); | ||||||
| 			continue; | 			continue; | ||||||
|  | 		} | ||||||
| 		if (!regexec(®ex, filename, 0, NULL, 0)) { | 		if (!regexec(®ex, filename, 0, NULL, 0)) { | ||||||
| 			bin = filters[i].bin; | 			bin = filters[i].bin; | ||||||
|  | 			regfree(®ex); | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
|  | 		regfree(®ex); | ||||||
| 	} | 	} | ||||||
| 	if (!bin) | 	if (!bin) | ||||||
| 		die("sent: Unable to find matching filter for file %s", filename); | 		die("sent: Unable to find matching filter for file %s", filename); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user