From ec0de4afa8f6119a737f731433134bed4fc48f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st> Date: Mon, 18 Feb 2019 12:00:55 +0200 Subject: [PATCH] dir_scan: Avoid allocating new copies of buf_dir This allocation is currently leaked, but as long as we don't allocate new ones for each refresh, that shouldn't be much of an issue. (cherry picked from commit 9dc2d32a8fb557112f8f96cd14d50b934543ce39) --- src/dir_scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dir_scan.c b/src/dir_scan.c index 9483d01..442c4a2 100644 --- a/src/dir_scan.c +++ b/src/dir_scan.c @@ -312,6 +312,7 @@ void dir_scan_init(const char *path) { dir_setlasterr(NULL); dir_seterr(NULL); dir_process = process; - buf_dir = malloc(dir_memsize("")); + if (!buf_dir) + buf_dir = malloc(dir_memsize("")); pstate = ST_CALC; } -- GitLab