From 4a6621892bc10d1e925d628ddd2ebd79cebe0466 Mon Sep 17 00:00:00 2001 From: yuxiaojun Date: Wed, 7 Dec 2022 16:09:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=A9=BA=E6=8C=87=E9=92=88=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easylogger/plugins/file/elog_file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/easylogger/plugins/file/elog_file.c b/easylogger/plugins/file/elog_file.c index efc3905..d05dfbb 100755 --- a/easylogger/plugins/file/elog_file.c +++ b/easylogger/plugins/file/elog_file.c @@ -113,6 +113,9 @@ void elog_file_write(const char *log, size_t size) ELOG_ASSERT(init_ok); ELOG_ASSERT(log); + if(fp == NULL) { + return; + } elog_file_port_lock(); From 28727e7ddd32d636adca4887673c1e1000428c6a Mon Sep 17 00:00:00 2001 From: yuxiaojun Date: Wed, 7 Dec 2022 16:31:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E9=9C=80=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easylogger/plugins/file/elog_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easylogger/plugins/file/elog_file.c b/easylogger/plugins/file/elog_file.c index d05dfbb..8327b9f 100755 --- a/easylogger/plugins/file/elog_file.c +++ b/easylogger/plugins/file/elog_file.c @@ -69,7 +69,7 @@ static bool elog_file_rotate(void) #define SUFFIX_LEN 10 /* mv xxx.log.n-1 => xxx.log.n, and xxx.log => xxx.log.0 */ int n, err = 0; - char oldpath[256], newpath[256]; + char oldpath[256]= {0}, newpath[256] = {0}; size_t base = strlen(local_cfg.name); bool result = true; FILE *tmp_fp;