Skip to content

Commit f81caf3

Browse files
authored
Fix multiplication result may overflow 'int' before it is converted to 'size_t'. (#911)
1 parent d709339 commit f81caf3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/utils/fluid_ringbuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* only be one producer thread and one consumer thread.
4040
*/
4141
fluid_ringbuffer_t *
42-
new_fluid_ringbuffer(int count, int elementsize)
42+
new_fluid_ringbuffer(int count, size_t elementsize)
4343
{
4444
fluid_ringbuffer_t *queue;
4545

src/utils/fluid_ringbuffer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ struct _fluid_ringbuffer_t
3333
fluid_atomic_int_t count; /**< Current count of elements */
3434
int in; /**< Index in queue to store next pushed element */
3535
int out; /**< Index in queue of next popped element */
36-
int elementsize; /**< Size of each element */
36+
size_t elementsize; /**< Size of each element */
3737
void *userdata;
3838
};
3939

4040
typedef struct _fluid_ringbuffer_t fluid_ringbuffer_t;
4141

4242

43-
fluid_ringbuffer_t *new_fluid_ringbuffer(int count, int elementsize);
43+
fluid_ringbuffer_t *new_fluid_ringbuffer(int count, size_t elementsize);
4444
void delete_fluid_ringbuffer(fluid_ringbuffer_t *queue);
4545

4646
/**

0 commit comments

Comments
 (0)