Commit 412898bb authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

block: fix invalid memory access in block_Fifo(Count|Size)

The function remain fundamentally ToCToU-prone, but at least they now
follow the memory model.
parent 318c24cb
......@@ -315,7 +315,7 @@ VLC_API size_t block_FifoPut( block_fifo_t *, block_t * );
VLC_API void block_FifoWake( block_fifo_t * );
VLC_API block_t * block_FifoGet( block_fifo_t * ) VLC_USED;
VLC_API block_t * block_FifoShow( block_fifo_t * );
size_t block_FifoSize( const block_fifo_t *p_fifo ) VLC_USED;
VLC_API size_t block_FifoCount( const block_fifo_t *p_fifo ) VLC_USED;
size_t block_FifoSize(block_fifo_t *) VLC_USED;
VLC_API size_t block_FifoCount(block_fifo_t *) VLC_USED;
#endif /* VLC_BLOCK_H */
......@@ -723,14 +723,24 @@ block_t *block_FifoShow( block_fifo_t *p_fifo )
return b;
}
/* FIXME: not thread-safe */
size_t block_FifoSize( const block_fifo_t *p_fifo )
/* FIXME: not (really) thread-safe */
size_t block_FifoSize (block_fifo_t *fifo)
{
return p_fifo->i_size;
size_t size;
vlc_mutex_lock (&fifo->lock);
size = fifo->i_size;
vlc_mutex_unlock (&fifo->lock);
return size;
}
/* FIXME: not thread-safe */
size_t block_FifoCount( const block_fifo_t *p_fifo )
/* FIXME: not (really) thread-safe */
size_t block_FifoCount (block_fifo_t *fifo)
{
return p_fifo->i_depth;
size_t depth;
vlc_mutex_lock (&fifo->lock);
depth = fifo->i_depth;
vlc_mutex_unlock (&fifo->lock);
return depth;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment