From d6a5264a9df5a8cddb8c4ad04998618bf98f7190 Mon Sep 17 00:00:00 2001 From: Sam James Date: Wed, 25 Jan 2023 03:47:10 +0000 Subject: librc: fix 'init' memory leak From scan-build w/ clang-16.0.0_pre20230107: ``` ../src/librc/librc.c:759:14: warning: Potential leak of memory pointed to by 'init' [unix.Malloc] return false; ^~~~~ ``` --- src/librc/librc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/librc/librc.c') diff --git a/src/librc/librc.c b/src/librc/librc.c index 7802cc41..34598529 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -755,8 +755,10 @@ rc_service_mark(const char *service, const RC_SERVICE state) RC_SVCDIR "/%s/%s", rc_parse_service_state(RC_SERVICE_WASINACTIVE), base); - if (symlink(init, was) == -1) + if (symlink(init, was) == -1) { + free(init); return false; + } skip_wasinactive = true; } if (unlink(file) == -1) { -- cgit v1.2.3