lib: Handle call to zlog_5424_cycle() without valid FD properly

In zlog_5424_cycle(), struct zlt_5424 *zlt only points to valid memory when
the passed file descriptor is >= 0 (and passing -1 seems to be a supported
use case). So we shouldn't try to compute the address of its zt member when
zlt is NULL.

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
This commit is contained in:
Martin Buck 2025-01-06 15:35:30 +01:00
parent 9951da394a
commit 59ee9d2a79

View file

@ -782,7 +782,7 @@ static void zlog_5424_cycle(struct zlog_cfg_5424 *zcf, int fd)
} }
old = zcf->active ? &zcf->active->zt : NULL; old = zcf->active ? &zcf->active->zt : NULL;
old = zlog_target_replace(old, &zlt->zt); old = zlog_target_replace(old, zlt ? &zlt->zt : NULL);
zcf->active = zlt; zcf->active = zlt;
/* oldt->fd == fd happens for zlog_5424_apply_meta() */ /* oldt->fd == fd happens for zlog_5424_apply_meta() */