From c1edc0901e983c456d53c5dffbd72bd4aebe0419 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 11 Apr 2024 10:51:33 +0800 Subject: [PATCH] common/params.cc: unlink tmp_path only if there's an error (#32145) --- common/params.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/params.cc b/common/params.cc index 38d96a30b0ffa5..8635f30d266145 100644 --- a/common/params.cc +++ b/common/params.cc @@ -273,7 +273,9 @@ int Params::put(const char* key, const char* value, size_t value_size) { } while (false); close(tmp_fd); - ::unlink(tmp_path.c_str()); + if (result != 0) { + ::unlink(tmp_path.c_str()); + } return result; }