Merge pull request #7047 from qlyoung/fix-zlog-target-null-deref

lib: fix possible null dereference in zlog
This commit is contained in:
Mark Stapp 2020-09-08 15:25:08 -04:00 committed by GitHub
commit 000ce30ee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,10 +225,11 @@ static bool zlog_file_cycle(struct zlog_cfg_file *zcf)
zlt->zt.logfn_sigsafe = zlog_fd_sigsafe;
} while (0);
old = zlog_target_replace(&zcf->active->zt, &zlt->zt);
old = zlog_target_replace(zcf->active ? &zcf->active->zt : NULL,
zlt ? &zlt->zt : NULL);
zcf->active = zlt;
zlog_file_target_free(container_of(old, struct zlt_fd, zt));
zlog_file_target_free(container_of_null(old, struct zlt_fd, zt));
return rv;
}