summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOneric <oneric@oneric.stub>2020-10-18 22:35:21 +0200
committerOleg Oshmyan <chortos@inbox.lv>2020-10-27 01:03:04 +0200
commit910211f1c0078e37546f73e95306724358b89be2 (patch)
tree901db828d64f9464a68a5958b0655985bc3d2c06
parent241e6137a5c9a4bfccbea48ce9eac75f7f13a784 (diff)
downloadlibass-910211f1c0078e37546f73e95306724358b89be2.tar.bz2
libass-910211f1c0078e37546f73e95306724358b89be2.tar.xz
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.
-rw-r--r--libass/ass.c10
-rw-r--r--libass/ass_priv.h4
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;