mirror of https://code.videolan.org/videolan/vlc
core: use <stdckdint.h>
This commit is contained in:
parent
167633ace0
commit
444d71bf2a
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdckdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
@ -47,7 +48,7 @@ static struct vlc_res **vlc_obj_res(vlc_object_t *obj)
|
|||
|
||||
void *vlc_objres_new(size_t size, void (*release)(void *))
|
||||
{
|
||||
if (unlikely(add_overflow(sizeof (struct vlc_res), size, &size)))
|
||||
if (unlikely(ckd_add(&size, sizeof (struct vlc_res), size)))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
|
@ -145,7 +146,7 @@ void *(vlc_obj_malloc)(vlc_object_t *obj, size_t size)
|
|||
void *(vlc_obj_calloc)(vlc_object_t *obj, size_t nmemb, size_t size)
|
||||
{
|
||||
size_t tabsize;
|
||||
if (unlikely(mul_overflow(nmemb, size, &tabsize)))
|
||||
if (unlikely(ckd_mul(&tabsize, nmemb, size)))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#endif
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdckdint.h>
|
||||
|
||||
#include <vlc_common.h>
|
||||
#include "picture.h"
|
||||
|
@ -161,8 +162,8 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
|
|||
|
||||
unsigned width, height;
|
||||
|
||||
if (unlikely(add_overflow(fmt->i_width, i_modulo_w - 1, &width))
|
||||
|| unlikely(add_overflow(fmt->i_height, i_modulo_h - 1, &height)))
|
||||
if (unlikely(ckd_add(&width, fmt->i_width, i_modulo_w - 1))
|
||||
|| unlikely(ckd_add(&height, fmt->i_height, i_modulo_h - 1)))
|
||||
return VLC_EGENERIC;
|
||||
|
||||
width = width / i_modulo_w * i_modulo_w;
|
||||
|
@ -298,8 +299,8 @@ picture_t *picture_NewFromFormat(const video_format_t *restrict fmt)
|
|||
{
|
||||
const plane_t *p = &pic->p[i];
|
||||
|
||||
if (unlikely(mul_overflow(p->i_pitch, p->i_lines, &plane_sizes[i]))
|
||||
|| unlikely(add_overflow(pic_size, plane_sizes[i], &pic_size)))
|
||||
if (unlikely(ckd_mul(&plane_sizes[i], p->i_pitch, p->i_lines))
|
||||
|| unlikely(ckd_add(&pic_size, pic_size, plane_sizes[i])))
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdckdint.h>
|
||||
|
||||
#include <vlc_common.h>
|
||||
#include "player.h"
|
||||
|
@ -103,9 +104,9 @@ vlc_player_title_list_Create(input_title_t *const *array, size_t count,
|
|||
|
||||
/* Allocate the struct + the whole list */
|
||||
size_t size;
|
||||
if (mul_overflow(count, sizeof(struct vlc_player_title), &size))
|
||||
if (ckd_mul(&size, count, sizeof(struct vlc_player_title)))
|
||||
return NULL;
|
||||
if (add_overflow(size, sizeof(struct vlc_player_title_list), &size))
|
||||
if (ckd_add(&size, size, sizeof(struct vlc_player_title_list)))
|
||||
return NULL;
|
||||
struct vlc_player_title_list *titles = malloc(size);
|
||||
if (!titles)
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdckdint.h>
|
||||
|
||||
#include <vlc_common.h>
|
||||
#include <vlc_memstream.h>
|
||||
|
||||
|
@ -147,8 +149,8 @@ size_t vlc_memstream_write(struct vlc_memstream *ms, const void *ptr,
|
|||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
if (unlikely(add_overflow(ms->length, len, &newlen))
|
||||
|| unlikely(add_overflow(newlen, 1, &newlen)))
|
||||
if (unlikely(ckd_add(&newlen, ms->length, len))
|
||||
|| unlikely(ckd_add(&newlen, newlen, 1)))
|
||||
goto error;
|
||||
|
||||
char *base = realloc(ms->ptr, newlen);
|
||||
|
@ -190,8 +192,8 @@ int vlc_memstream_vprintf(struct vlc_memstream *ms, const char *fmt,
|
|||
va_end(ap);
|
||||
|
||||
if (len < 0
|
||||
|| unlikely(add_overflow(ms->length, len, &newlen))
|
||||
|| unlikely(add_overflow(newlen, 1, &newlen)))
|
||||
|| unlikely(ckd_add(&newlen, ms->length, len))
|
||||
|| unlikely(ckd_add(&newlen, newlen, 1)))
|
||||
goto error;
|
||||
|
||||
ptr = realloc(ms->ptr, newlen);
|
||||
|
|
Loading…
Reference in New Issue