Check the thread is ready before adding events

Prevents segmentation faults when accessing the NULL stream buffer
without a clear message of what is happening.
This commit is contained in:
Rodrigo Arias 2023-12-19 13:02:46 +01:00
parent 0439399f05
commit 6bfacf0e1e
2 changed files with 8 additions and 0 deletions

View File

@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Calling `ovni_thread_isready()` after `ovni_thread_free()` now returns 0.
- Emitting events in a non-ready thread now aborts the program with a
message rather than causing a segfault.
## [1.5.0] - 2023-12-15

View File

@ -767,6 +767,9 @@ add_flush_events(uint64_t t0, uint64_t t1)
static void
ovni_ev_add_jumbo(struct ovni_ev *ev, const uint8_t *buf, uint32_t bufsize)
{
if (!rthread.ready)
die("thread is not initialized");
int flushed = 0;
uint64_t t0, t1;
@ -808,6 +811,9 @@ ovni_ev_add_jumbo(struct ovni_ev *ev, const uint8_t *buf, uint32_t bufsize)
static void
ovni_ev_add(struct ovni_ev *ev)
{
if (!rthread.ready)
die("thread is not initialized");
int flushed = 0;
uint64_t t0, t1;