History

avcodec/xpmdec: Avoid unnecessary size_t->int conversion

Andreas Rheinhardt committed 2 years ago

Commit 357e3391 parent 64634e81 file · +3 −4Browse files

Unified · Split

libavcodec/xpmdec.c+3−4
@@ -233,14 +233,12 @@ static size_t mod_strcspn(const char *string, const char *reject) · 232 unmodified lines
233 return i;233 return i;
234}234}
235 235
236static uint32_t color_string_to_rgba(const char *p, int len)236static uint32_t color_string_to_rgba(const char *p, size_t len)
237{237{
238 uint32_t ret = 0xFF000000;238 uint32_t ret = 0xFF000000;
239 const ColorEntry *entry;239 const ColorEntry *entry;
240 char color_name[100];240 char color_name[100];
241 241
242 len = FFMIN(FFMAX(len, 0), sizeof(color_name) - 1);
243
244 if (*p == '#') {242 if (*p == '#') {
245 p++;243 p++;
246 len--;244 len--;
@@ -271,6 +269,7 @@ static uint32_t color_string_to_rgba(const char *p, int len) · 24 unmodified lines
271 (hex_char_to_number(p[0]) << 28);269 (hex_char_to_number(p[0]) << 28);
272 }270 }
273 } else {271 } else {
272 len = FFMIN(len, sizeof(color_name) - 1);
274 strncpy(color_name, p, len);273 strncpy(color_name, p, len);
275 color_name[len] = '\0';274 color_name[len] = '\0';
276 275
@@ -375,7 +374,7 @@ static int xpm_decode_frame(AVCodecContext *avctx, AVFrame *p, · 98 unmodified lines
375 374
376 for (i = 0; i < ncolors; i++) {375 for (i = 0; i < ncolors; i++) {
377 const uint8_t *index;376 const uint8_t *index;
378 int len;377 size_t len;
379 378
380 ptr += mod_strcspn(ptr, "\"") + 1;379 ptr += mod_strcspn(ptr, "\"") + 1;
381 if (end - ptr < cpp)380 if (end - ptr < cpp)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t