Skip to content

Commit 3c7cd35

Browse files
authored
Maybe make bsvmovie more tolerant of msgpack encoding (#18342)
1 parent ef9dc83 commit 3c7cd35

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

input/bsv/bsvmovie.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,41 +1436,41 @@ bool bsv_movie_read_deduped_state(bsv_movie_t *movie, uint8_t *encoded, size_t e
14361436
}
14371437
total_decode_count++;
14381438
rmsgpack_dom_read_with(read_mem, &item, reader_state);
1439-
if(item.type != RDT_INT)
1439+
if(item.type != RDT_INT && item.type != RDT_UINT)
14401440
{
14411441
RARCH_ERR("[STATESTREAM] start token type is wrong\n");
14421442
goto exit;
14431443
}
1444-
if(item.val.int_ != BSV_IFRAME_START_TOKEN)
1444+
if(item.val.uint_ != BSV_IFRAME_START_TOKEN)
14451445
{
14461446
RARCH_ERR("[STATESTREAM] start token value is wrong\n");
14471447
goto exit;
14481448
}
14491449
rmsgpack_dom_read_with(read_mem, &item, reader_state);
1450-
if(item.type != RDT_INT)
1450+
if(item.type != RDT_INT && item.type != RDT_UINT)
14511451
{
14521452
RARCH_ERR("[STATESTREAM] frame counter type is wrong\n");
14531453
goto exit;
14541454
}
1455-
/*frame_counter = item.val.int_;*/
1455+
/*frame_counter = item.val.uint_;*/
14561456
while(rmsgpack_dom_read_with(read_mem, &item, reader_state) >= 0)
14571457
{
14581458
uint32_t index, *superblock;
14591459
size_t len;
1460-
if(item.type != RDT_INT)
1460+
if(item.type != RDT_INT && item.type != RDT_UINT)
14611461
{
14621462
RARCH_ERR("[STATESTREAM] state update chunk token type is wrong\n");
14631463
goto exit;
14641464
}
1465-
switch(item.val.int_) {
1465+
switch(item.val.uint_) {
14661466
case BSV_IFRAME_NEW_BLOCK_TOKEN:
14671467
rmsgpack_dom_read_with(read_mem, &item, reader_state);
1468-
if(item.type != RDT_INT)
1468+
if(item.type != RDT_INT && item.type != RDT_UINT)
14691469
{
14701470
RARCH_ERR("[STATESTREAM] new block index type is wrong\n");
14711471
goto exit;
14721472
}
1473-
index = item.val.int_;
1473+
index = item.val.uint_;
14741474
rmsgpack_dom_read_with(read_mem, &item, reader_state);
14751475
if(item.type != RDT_BINARY)
14761476
{
@@ -1494,12 +1494,12 @@ bool bsv_movie_read_deduped_state(bsv_movie_t *movie, uint8_t *encoded, size_t e
14941494
break;
14951495
case BSV_IFRAME_NEW_SUPERBLOCK_TOKEN:
14961496
rmsgpack_dom_read_with(read_mem, &item, reader_state);
1497-
if(item.type != RDT_INT)
1497+
if(item.type != RDT_INT && item.type != RDT_UINT)
14981498
{
14991499
RARCH_ERR("[STATESTREAM] new superblock index type is wrong\n");
15001500
goto exit;
15011501
}
1502-
index = item.val.int_;
1502+
index = item.val.uint_;
15031503
if(rmsgpack_dom_read_with(read_mem, &item, reader_state) < 0)
15041504
{
15051505
RARCH_ERR("[STATESTREAM] array read failed\n");
@@ -1520,8 +1520,8 @@ bool bsv_movie_read_deduped_state(bsv_movie_t *movie, uint8_t *encoded, size_t e
15201520
for(i = 0; i < len; i++)
15211521
{
15221522
struct rmsgpack_dom_value inner_item = item.val.array.items[i];
1523-
/* assert(inner_item.type == RDT_INT); */
1524-
superblock[i] = inner_item.val.int_;
1523+
/* assert(inner_item.type == RDT_INT || inner_item.type == RDT_UINT); */
1524+
superblock[i] = inner_item.val.uint_;
15251525
}
15261526
if(!uint32s_index_insert_exact(movie->superblocks, index, superblock, movie->frame_counter))
15271527
{
@@ -1546,8 +1546,8 @@ bool bsv_movie_read_deduped_state(bsv_movie_t *movie, uint8_t *encoded, size_t e
15461546
for(i = 0; i < len; i++)
15471547
{
15481548
struct rmsgpack_dom_value inner_item = item.val.array.items[i];
1549-
/* assert(inner_item.type == RDT_INT); */
1550-
uint32_t superblock_idx = inner_item.val.int_;
1549+
/* assert(inner_item.type == RDT_INT || inner_item.type == RDT_UINT); */
1550+
uint32_t superblock_idx = inner_item.val.uint_;
15511551
uint32_t *superblock;
15521552
size_t j;
15531553
/* if this superblock is the same as last time, no need to scan the blocks. */
@@ -1580,7 +1580,7 @@ bool bsv_movie_read_deduped_state(bsv_movie_t *movie, uint8_t *encoded, size_t e
15801580
ret = true;
15811581
goto exit;
15821582
default:
1583-
RARCH_ERR("[STATESTREAM] state update chunk token value is invalid: %d @ %x\n", item.val.int_, intfstream_tell(read_mem));
1583+
RARCH_ERR("[STATESTREAM] state update chunk token value is invalid: %d @ %x\n", item.val.uint_, intfstream_tell(read_mem));
15841584
goto exit;
15851585
}
15861586
}

0 commit comments

Comments
 (0)