[vlc-commits] [Git][videolan/vlc][master] 2 commits: clock: continue if logger is NULL
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Thu Jan 19 15:10:27 UTC 2023
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
0723d9cb by Thomas Guillem at 2023-01-19T14:52:55+00:00
clock: continue if logger is NULL
- - - - -
142317c3 by Thomas Guillem at 2023-01-19T14:52:55+00:00
log: fail if parent is NULL
parent can be NULL when preparsing, or doing thumbnail, for example.
Fixes a SIGSEGV when vlc_logger was deferencing its parent while logging.
- - - - -
2 changed files:
- src/clock/clock.c
- src/misc/messages.c
Changes:
=====================================
src/clock/clock.c
=====================================
@@ -154,9 +154,10 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
/* System and stream ts should be incrementing */
if (system_diff < 0 || stream_diff < 0)
{
- vlc_warning(main_clock->logger, "resetting master clock: "
- "decreasing ts: system: %"PRId64 ", stream: %" PRId64,
- system_diff, stream_diff);
+ if (main_clock->logger != NULL)
+ vlc_warning(main_clock->logger, "resetting master clock: "
+ "decreasing ts: system: %"PRId64 ", stream: %" PRId64,
+ system_diff, stream_diff);
/* Reset and continue (calculate the offset from the
* current point) */
vlc_clock_main_reset(main_clock);
@@ -165,8 +166,9 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
else if (instant_coeff > 1.0 + COEFF_THRESHOLD
|| instant_coeff < 1.0 - COEFF_THRESHOLD)
{
- vlc_warning(main_clock->logger, "resetting master clock: "
- "coefficient too unstable: %f", instant_coeff);
+ if (main_clock->logger != NULL)
+ vlc_warning(main_clock->logger, "resetting master clock: "
+ "coefficient too unstable: %f", instant_coeff);
/* Reset and continue (calculate the offset from the
* current point) */
vlc_clock_main_reset(main_clock);
@@ -283,7 +285,8 @@ vlc_clock_monotonic_to_system_locked(vlc_clock_t *clock, vlc_tick_t now,
if (pcr_delay > CR_MAX_GAP)
{
- vlc_error(main_clock->logger, "Invalid PCR delay ! Ignoring it...");
+ if (main_clock->logger != NULL)
+ vlc_error(main_clock->logger, "Invalid PCR delay ! Ignoring it...");
pcr_delay = 0;
}
@@ -434,11 +437,6 @@ vlc_clock_main_t *vlc_clock_main_New(struct vlc_logger *parent_logger, struct vl
return NULL;
main_clock->logger = vlc_LogHeaderCreate(parent_logger, "clock");
- if (main_clock->logger == NULL)
- {
- free(main_clock);
- return NULL;
- }
main_clock->tracer = parent_tracer;
vlc_mutex_init(&main_clock->lock);
@@ -539,7 +537,8 @@ void vlc_clock_main_ChangePause(vlc_clock_main_t *main_clock, vlc_tick_t now,
void vlc_clock_main_Delete(vlc_clock_main_t *main_clock)
{
assert(main_clock->rc == 1);
- vlc_LogDestroy(main_clock->logger);
+ if (main_clock->logger != NULL)
+ vlc_LogDestroy(main_clock->logger);
free(main_clock);
}
=====================================
src/misc/messages.c
=====================================
@@ -484,6 +484,9 @@ static const struct vlc_logger_operations header_ops = {
struct vlc_logger *vlc_LogHeaderCreate(struct vlc_logger *parent,
const char *str)
{
+ if (parent == NULL)
+ return NULL;
+
size_t len = strlen(str) + 1;
struct vlc_logger_header *header = malloc(sizeof (*header) + len);
if (unlikely(header == NULL))
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3f4e6a87a623919cd32bfa043ab4a096271eb049...142317c38d453a19917bef95754861931d7ba2cd
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3f4e6a87a623919cd32bfa043ab4a096271eb049...142317c38d453a19917bef95754861931d7ba2cd
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list