Skip to content

Commit

Permalink
Fix multiplication result may overflow 'int' before it is converted t…
Browse files Browse the repository at this point in the history
…o 'size_t'. (#911)
  • Loading branch information
derselbst committed Jun 12, 2021
1 parent d709339 commit f81caf3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/fluid_ringbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* only be one producer thread and one consumer thread.
*/
fluid_ringbuffer_t *
new_fluid_ringbuffer(int count, int elementsize)
new_fluid_ringbuffer(int count, size_t elementsize)
{
fluid_ringbuffer_t *queue;

Expand Down
4 changes: 2 additions & 2 deletions src/utils/fluid_ringbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ struct _fluid_ringbuffer_t
fluid_atomic_int_t count; /**< Current count of elements */
int in; /**< Index in queue to store next pushed element */
int out; /**< Index in queue of next popped element */
int elementsize; /**< Size of each element */
size_t elementsize; /**< Size of each element */
void *userdata;
};

typedef struct _fluid_ringbuffer_t fluid_ringbuffer_t;


fluid_ringbuffer_t *new_fluid_ringbuffer(int count, int elementsize);
fluid_ringbuffer_t *new_fluid_ringbuffer(int count, size_t elementsize);
void delete_fluid_ringbuffer(fluid_ringbuffer_t *queue);

/**
Expand Down

0 comments on commit f81caf3

Please sign in to comment.