@@ -6344,19 +6344,19 @@ void bsv_movie_read_next_events(bsv_movie_t *handle)
63446344 }
63456345 else if (next_frame_type == REPLAY_TOKEN_CHECKPOINT_FRAME )
63466346 {
6347- size_t size ;
6347+ size_t _len ;
63486348 uint8_t * state ;
63496349 retro_ctx_serialize_info_t serial_info ;
6350- if (intfstream_read (handle -> file , & size , sizeof (uint64_t )) != sizeof (uint64_t ))
6350+ if (intfstream_read (handle -> file , & _len , sizeof (uint64_t )) != sizeof (uint64_t ))
63516351 {
63526352 /* Unnatural EOF */
63536353 RARCH_ERR ("[Replay] Replay truncated before reading size.\n" );
63546354 input_st -> bsv_movie_state .flags |= BSV_FLAG_MOVIE_END ;
63556355 return ;
63566356 }
6357- size = swap_if_big64 (size );
6358- state = calloc (size , sizeof (uint8_t ));
6359- if (intfstream_read (handle -> file , state , size ) != (int64_t )size )
6357+ _len = swap_if_big64 (_len );
6358+ state = calloc (_len , sizeof (uint8_t ));
6359+ if (intfstream_read (handle -> file , state , _len ) != (int64_t )_len )
63606360 {
63616361 /* Unnatural EOF */
63626362 RARCH_ERR ("[Replay] Replay checkpoint truncated.\n" );
@@ -6365,7 +6365,7 @@ void bsv_movie_read_next_events(bsv_movie_t *handle)
63656365 return ;
63666366 }
63676367 serial_info .data_const = state ;
6368- serial_info .size = size ;
6368+ serial_info .size = _len ;
63696369 if (!core_unserialize (& serial_info ))
63706370 {
63716371 RARCH_ERR ("[Replay] Failed to load movie checkpoint, failing\n" );
@@ -6447,10 +6447,10 @@ void bsv_movie_next_frame(input_driver_state_t *input_st)
64476447 uint8_t compression = REPLAY_CHECKPOINT2_COMPRESSION_NONE ;
64486448#endif
64496449 uint8_t encoding = REPLAY_CHECKPOINT2_ENCODING_RAW ;
6450- size_t len = core_serialize_size ();
6451- uint8_t * st = (uint8_t * )malloc (len );
6450+ size_t _len = core_serialize_size ();
6451+ uint8_t * st = (uint8_t * )malloc (_len );
64526452 serial_info .data = st ;
6453- serial_info .size = len ;
6453+ serial_info .size = _len ;
64546454 core_serialize (& serial_info );
64556455 /* "next frame is a checkpoint" */
64566456 intfstream_write (handle -> file , (uint8_t * )(& frame_tok ), sizeof (uint8_t ));
@@ -6510,27 +6510,31 @@ bool replay_get_serialized_data(void* buffer)
65106510static bool replay_check_same_timeline (bsv_movie_t * movie ,
65116511 uint8_t * other_movie , int64_t other_len )
65126512{
6513- int64_t check_limit = MIN (other_len , intfstream_tell (movie -> file ));
6514- intfstream_t * check_stream = intfstream_open_memory (other_movie , RETRO_VFS_FILE_ACCESS_READ , RETRO_VFS_FILE_ACCESS_HINT_NONE , other_len );
6515- bool ret = true;
6516- int64_t check_cap = MAX (128 << 10 , MAX (128 * sizeof (bsv_key_data_t ), 512 * sizeof (bsv_input_data_t )));
6517- uint8_t * buf1 = calloc (check_cap ,1 ), * buf2 = calloc (check_cap ,1 );
6518- size_t movie_pos = intfstream_tell (movie -> file );
65196513 uint64_t size1 , size2 ;
65206514 uint16_t btncount1 , btncount2 ;
6521- uint8_t frametok1 = 0 ;
6522- uint8_t frametok2 = 0 ;
6523- uint8_t keycount1 = 0 ;
6524- uint8_t keycount2 = 0 ;
6515+ int64_t check_limit = MIN (other_len , intfstream_tell (movie -> file ));
6516+ intfstream_t * check_stream = intfstream_open_memory (other_movie , RETRO_VFS_FILE_ACCESS_READ , RETRO_VFS_FILE_ACCESS_HINT_NONE , other_len );
6517+ bool ret = true;
6518+ int64_t check_cap = MAX (128 << 10 , MAX (128 * sizeof (bsv_key_data_t ), 512 * sizeof (bsv_input_data_t )));
6519+ uint8_t * buf1 = (uint8_t * )calloc (check_cap ,1 );
6520+ uint8_t * buf2 = (uint8_t * )calloc (check_cap ,1 );
6521+ size_t movie_pos = intfstream_tell (movie -> file );
6522+ uint8_t frametok1 = 0 ;
6523+ uint8_t frametok2 = 0 ;
6524+ uint8_t keycount1 = 0 ;
6525+ uint8_t keycount2 = 0 ;
6526+
65256527 intfstream_rewind (movie -> file );
65266528 intfstream_read (movie -> file , buf1 , 6 * sizeof (uint32_t ));
65276529 intfstream_read (check_stream , buf2 , 6 * sizeof (uint32_t ));
6530+
65286531 if (memcmp (buf1 , buf2 , 6 * sizeof (uint32_t )) != 0 )
65296532 {
65306533 RARCH_ERR ("[Replay] Headers of two movies differ, not same timeline\n" );
65316534 ret = false;
65326535 goto exit ;
65336536 }
6537+
65346538 intfstream_seek (movie -> file , movie -> min_file_pos , SEEK_SET );
65356539 /* assumption: both headers have the same state size */
65366540 intfstream_seek (check_stream , movie -> min_file_pos , SEEK_SET );
@@ -6714,9 +6718,9 @@ bool replay_set_serialized_data(void* buf)
67146718
67156719 if (ident == movie -> identifier ) /* is compatible? */
67166720 {
6717- int64_t loaded_len = (int64_t )swap_if_big32 (((uint32_t * )buffer )[0 ]);
6718- int64_t handle_idx = intfstream_tell (movie -> file );
6719- bool same_timeline = replay_check_same_timeline (movie , (uint8_t * )header , loaded_len );
6721+ int64_t _len = (int64_t )swap_if_big32 (((uint32_t * )buffer )[0 ]);
6722+ int64_t handle_idx = intfstream_tell (movie -> file );
6723+ bool same_timeline = replay_check_same_timeline (movie , (uint8_t * )header , _len );
67206724 /* If the state is part of this replay, go back to that state
67216725 and rewind/fast forward the replay.
67226726
@@ -6727,7 +6731,7 @@ bool replay_set_serialized_data(void* buf)
67276731
67286732 This can truncate the current replay if we're in recording mode.
67296733 */
6730- if (playback && loaded_len > handle_idx )
6734+ if (playback && _len > handle_idx )
67316735 {
67326736 const char * _msg = msg_hash_to_str (MSG_REPLAY_LOAD_STATE_FAILED_FUTURE_STATE );
67336737 runloop_msg_queue_push (_msg , strlen (_msg ), 1 , 180 , true, NULL ,
@@ -6743,7 +6747,7 @@ bool replay_set_serialized_data(void* buf)
67436747 RARCH_ERR ("[Replay] %s.\n" , _msg );
67446748 return false;
67456749 }
6746- else if (recording && (loaded_len > handle_idx || !same_timeline ))
6750+ else if (recording && (_len > handle_idx || !same_timeline ))
67476751 {
67486752 if (!same_timeline )
67496753 {
@@ -6753,13 +6757,13 @@ bool replay_set_serialized_data(void* buf)
67536757 RARCH_WARN ("[Replay] %s.\n" , _msg );
67546758 }
67556759 intfstream_rewind (movie -> file );
6756- intfstream_write (movie -> file , buffer + sizeof (int32_t ), loaded_len );
6760+ intfstream_write (movie -> file , buffer + sizeof (int32_t ), _len );
67576761 }
67586762 else
67596763 {
6760- intfstream_seek (movie -> file , loaded_len , SEEK_SET );
6764+ intfstream_seek (movie -> file , _len , SEEK_SET );
67616765 if (recording )
6762- intfstream_truncate (movie -> file , loaded_len );
6766+ intfstream_truncate (movie -> file , _len );
67636767 }
67646768 }
67656769 else
0 commit comments