qi: Fix 'rootdir' value, include post-install from proper location
[dragora.git] / patches / findutils / 9ad78c90c77636b5491f63470ed241123ca85cf6
blob54c4ff1c9769f272cc4800c3de9941e3a2c60b83
1 From 9ad78c90c77636b5491f63470ed241123ca85cf6 Mon Sep 17 00:00:00 2001
2 From: Bernhard Voelker <mail@bernhard-voelker.de>
3 Date: Thu, 29 Aug 2019 08:36:26 +0200
4 Subject: find: fix minor memory leak in sharefile handling
6 When sharefile_fopen fails to open the given file, e.g. due to the lack
7 of permissions, then the name of the file is not freed.
9 $ valgrind -v --leak-check=full find/find . -maxdepth 0 -fprint /
10 ...
11 ==28139== 2 bytes in 1 blocks are definitely lost in loss record 2 of 11
12 ==28139==    at 0x483677F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
13 ==28139==    by 0x4923DBA: strdup (strdup.c:42)
14 ==28139==    by 0x409E80: sharefile_fopen (sharefile.c:150)
15 ==28139==    by 0x40CCA0: open_output_file (parser.c:3390)
16 ==28139==    by 0x40CFA8: parse_fprint (parser.c:1010)
17 ==28139==    by 0x408341: build_expression_tree (tree.c:1295)
18 ==28139==    by 0x403AF7: main (ftsfind.c:712)
20 This memory leak is a trivial issue because find will terminate anyway
21 due to the error.
23 * find/sharefile.c (sharefile_open): Call entry_free instead of simple
24 free to also free the strdup-ed filename.
25 ---
26  find/sharefile.c | 2 +-
27  1 file changed, 1 insertion(+), 1 deletion(-)
29 diff --git a/find/sharefile.c b/find/sharefile.c
30 index 02d25cc..e82aec1 100644
31 --- a/find/sharefile.c
32 +++ b/find/sharefile.c
33 @@ -156,7 +156,7 @@ sharefile_fopen (sharefile_handle h, const char *filename)
35    if (NULL == (new_entry->fp = fopen_safer (filename, p->mode)))
36      {
37 -      free (new_entry);
38 +      entry_free (new_entry);
39        return NULL;
40      }
41    else
42 -- 
43 cgit v1.0-41-gc330