UltraStar-Deluxe / USDX

The free and open source karaoke singing game UltraStar Deluxe, inspired by Sony SingStarâ„¢
https://usdx.eu
GNU General Public License v2.0
832 stars 160 forks source link

PByteArray vs array of uint8 without size definition except integer size descriptor #187

Closed basisbit closed 7 years ago

basisbit commented 7 years ago

Was working on ffmpeg 3 support the last few hours and noticed an issue: @brianch , you translated the headers of ffmpeg. https://github.com/UltraStar-Deluxe/USDX/blob/master/src/lib/ffmpeg-3.1/avcodec.pas#L1954 shows that array of uint8/byte was translated as PByteArray (array with max 32767 elementss of type byte). According to my understanding of https://www.ffmpeg.org/doxygen/3.1/avcodec_8h_source.html line 1580, this is not correct as this should be an array of type Byte with undefined size and sizing it in the range from 0 to High(Integer) as the size is always described as Integer. A PByteArray would be too small and thus cause index out of bounds errors.

Is my understanding of freepascal wrong in this case or should we actually fix the type of the audio buffers?

brianch commented 7 years ago

Thanks for reporting, from what I saw in the ffmpeg online documentation this field was always a uint8_t, so the older ffmpeg header had the same problem, I changed all the versions* (replaced the type by 'Pcuint8') on the commit that closed this issue (and the 3.2 on the ffmpeg3+ branch).

-- *all but the one named 'ffmpeg', as I still couldn't check the versions it refers to (but anyway I think it's very rarely if used at all).

AlexanderS commented 7 years ago

The src/lib/ffmpeg/ directory is oldest and is only used for all versions before ffmpeg-0.10.

basisbit commented 7 years ago

thanks @brianch for fixing this! My experience with freepascal is still quite limited, so I couldn't have done that.

basisbit commented 7 years ago

reopening this. it should definitely be a pointer to an array. Pcuint8 is just simply a single byte.

brianch commented 7 years ago

Are you sure? The definition in the C code is:

uint8_t *data;

(line 1580 in the ffmpeg source)

it is not a pointer to an array.

Goostav5 commented 7 years ago

Hi, I'm trying to build USDX on win7 and looks like commit (https://github.com/UltraStar-Deluxe/USDX/commit/0c08358d78801f9fb50feac5835b71fe6f8a4e6a) causes an error. Am I doing something wrong maybe? image