diff: free state populated via options
The `objfind` and `anchors` members of `struct diff_options` are populated via option parsing, but are never freed in `diff_free()`. Fix this to plug those memory leaks. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									0aaca0ec09
								
							
						
					
					
						commit
						36f971f861
					
				
							
								
								
									
										10
									
								
								diff.c
								
								
								
								
							
							
						
						
									
										10
									
								
								diff.c
								
								
								
								
							|  | @ -6717,6 +6717,16 @@ void diff_free(struct diff_options *options) | ||||||
| 	if (options->no_free) | 	if (options->no_free) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
|  | 	if (options->objfind) { | ||||||
|  | 		oidset_clear(options->objfind); | ||||||
|  | 		FREE_AND_NULL(options->objfind); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	for (size_t i = 0; i < options->anchors_nr; i++) | ||||||
|  | 		free(options->anchors[i]); | ||||||
|  | 	FREE_AND_NULL(options->anchors); | ||||||
|  | 	options->anchors_nr = options->anchors_alloc = 0; | ||||||
|  |  | ||||||
| 	diff_free_file(options); | 	diff_free_file(options); | ||||||
| 	diff_free_ignore_regex(options); | 	diff_free_ignore_regex(options); | ||||||
| 	clear_pathspec(&options->pathspec); | 	clear_pathspec(&options->pathspec); | ||||||
|  |  | ||||||
|  | @ -1,6 +1,8 @@ | ||||||
| #!/bin/sh | #!/bin/sh | ||||||
|  |  | ||||||
| test_description='test finding specific blobs in the revision walking' | test_description='test finding specific blobs in the revision walking' | ||||||
|  |  | ||||||
|  | TEST_PASSES_SANITIZE_LEAK=true | ||||||
| . ./test-lib.sh | . ./test-lib.sh | ||||||
|  |  | ||||||
| test_expect_success 'setup ' ' | test_expect_success 'setup ' ' | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
|  |  | ||||||
| test_description='anchored diff algorithm' | test_description='anchored diff algorithm' | ||||||
|  |  | ||||||
|  | TEST_PASSES_SANITIZE_LEAK=true | ||||||
| . ./test-lib.sh | . ./test-lib.sh | ||||||
|  |  | ||||||
| test_expect_success '--anchored' ' | test_expect_success '--anchored' ' | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
|  |  | ||||||
| test_description='remerge-diff handling' | test_description='remerge-diff handling' | ||||||
|  |  | ||||||
|  | TEST_PASSES_SANITIZE_LEAK=true | ||||||
| . ./test-lib.sh | . ./test-lib.sh | ||||||
|  |  | ||||||
| # This test is ort-specific | # This test is ort-specific | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Patrick Steinhardt
						Patrick Steinhardt