xiph / theora

Reference implementation of the Theora video compression format.
https://theora.org/
Other
98 stars 66 forks source link

Fix crash #2

Closed comeradealexi closed 7 years ago

comeradealexi commented 7 years ago

If these pointers aren't zero, then the sample will crash.

Test for yourself by putting a random value into these pointers.

tdaede commented 7 years ago

Global variables are initialized to zero in C. Is there any real-world case where you hit this bug?

comeradealexi commented 7 years ago

Ah, interesting. I was using parts of the sample program to put into a C++ project, I never knew this difference existed between C++ and C!

Might help others like myself being caught out in the future if it was explicitly initialised, even though it's not a C bug :)

Alex

rillian commented 7 years ago

IIRC there are other issues with compiling theora as C++ instead of C. Perhaps we should

#if defined(__cplusplus)
#error Theora must be compiled as C, not C++!
#endif

everywhere?

rillian commented 7 years ago

Applied with corresponding changes to the other examples and an updated commit message in 91203fdfdc0eb06cd87409d47e35d9ee5471a90f.