@@ -242,11 +242,23 @@ int64_t retro_vfs_file_seek_internal(
242242#endif
243243#ifdef ATLEAST_VC2005
244244 /* VC2005 and up have a special 64-bit fseek */
245- return _fseeki64 (stream -> fp , offset , whence );
245+ if (_fseeki64 (stream -> fp , offset , whence ) != 0 )
246+ return -1 ;
247+ if ((val = _ftelli64 (stream -> fp )) < 0 )
248+ return -1 ;
249+ return val ;
246250#elif defined(HAVE_64BIT_OFFSETS )
247- return fseeko (stream -> fp , (off_t )offset , whence );
251+ if (fseeko (stream -> fp , (off_t )offset , whence ) != 0 )
252+ return -1 ;
253+ if ((val = ftello (stream -> fp )) < 0 )
254+ return -1 ;
255+ return val ;
248256#else
249- return fseek (stream -> fp , (long )offset , whence );
257+ if (fseek (stream -> fp , (long )offset , whence ) != 0 )
258+ return -1 ;
259+ if ((val = ftell (stream -> fp )) < 0 )
260+ return -1 ;
261+ return val ;
250262#endif
251263 }
252264#ifdef HAVE_MMAP
@@ -718,11 +730,17 @@ int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream)
718730#endif
719731#ifdef ATLEAST_VC2005
720732 /* VC2005 and up have a special 64-bit ftell */
721- return _ftelli64 (stream -> fp );
733+ if ((val = _ftelli64 (stream -> fp )) < 0 )
734+ return -1 ;
735+ return val ;
722736#elif defined(HAVE_64BIT_OFFSETS )
723- return ftello (stream -> fp );
737+ if ((val = ftello (stream -> fp )) < 0 )
738+ return -1 ;
739+ return val ;
724740#else
725- return ftell (stream -> fp );
741+ if ((val = ftell (stream -> fp )) < 0 )
742+ return -1 ;
743+ return val ;
726744#endif
727745 }
728746#ifdef HAVE_MMAP
0 commit comments