From 910211f1c0078e37546f73e95306724358b89be2 Mon Sep 17 00:00:00 2001 From: Oneric Date: Sun, 18 Oct 2020 22:35:21 +0200 Subject: parser_priv: Change type of fontdata_{size,used} to size_t size_t is a more sensible type for as it is unsigned and accurately represents the theoretical limits of object size. int may be larger or smaller than size_t, which both would lead to problems and potential UB with signed overflow. There was no usage of negative values as error flags or similar and those two fields are not part of the public API, so this change should be safe. To stay consistent, also adjust types of related variables in functions. --- libass/ass.c | 10 +++++----- libass/ass_priv.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libass/ass.c b/libass/ass.c index 38dbde1..e7e2658 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -807,7 +807,7 @@ static int process_events_line(ASS_Track *track, char *str) } static unsigned char *decode_chars(const unsigned char *src, - unsigned char *dst, int cnt_in) + unsigned char *dst, size_t cnt_in) { uint32_t value = 0; for (int i = 0; i < cnt_in; i++) @@ -825,9 +825,9 @@ static int decode_font(ASS_Track *track) { unsigned char *p; unsigned char *q; - int i; - int size; // original size - int dsize; // decoded size + size_t i; + size_t size; // original size + size_t dsize; // decoded size unsigned char *buf = 0; ass_msg(track->library, MSGL_V, "Font: %d bytes encoded data", @@ -871,7 +871,7 @@ error_decode_font: static int process_fonts_line(ASS_Track *track, char *str) { - int len; + size_t len; if (!strncmp(str, "fontname:", 9)) { char *p = str + 9; diff --git a/libass/ass_priv.h b/libass/ass_priv.h index 98b2711..cd9447a 100644 --- a/libass/ass_priv.h +++ b/libass/ass_priv.h @@ -50,8 +50,8 @@ struct parser_priv { ParserState state; char *fontname; char *fontdata; - int fontdata_size; - int fontdata_used; + size_t fontdata_size; + size_t fontdata_used; // contains bitmap of ReadOrder IDs of all read events uint32_t *read_order_bitmap; -- cgit v1.2.3