Skip to content
  • Rémi Denis-Courmont's avatar
    stream: assert that read size is well defined · 3bf8a8ec
    Rémi Denis-Courmont authored
    The result of a read operation is a signed size_t, and cannot be
    negative (except on error). Thus reading more than SSIZE_MAX bytes at
    once is not well defined.
    
    (Note: POSIX marks it as implementation-defined, and we cannot rely on
     much given the different implementations.)
    
    In practice, this is not really a limitation for regular reads as
    allocating a contiguous output buffer of more than SSIZE_MAX bytes is
    essentially impossible. It can however be a problem when skipping data
    (buffer pointer is NULL), especially on 32-bits platforms.
    
    To skip such large amount of data, seeking is recommended instead,
    e.g.:
    
        vlc_stream_Seek(s, vlc_stream_Tell() + skip);
    
    instead of:
    
        vlc_stream_Read(s, NULL, skip);
    3bf8a8ec