Skip to content

Commit

Permalink
rid crash when reading Vorbis files on 32-bit platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBoersma committed Aug 15, 2021
1 parent e6d42bf commit c80187c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dwtools/Sound_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ autoSound Sound_readFromOggVorbisFile (MelderFile file) {
double xmin = 0.0; // the start time in the file can be > 0!!!
const double xmax = numberOfSamples * samplingTime;
autoSound me = Sound_create (numberOfChannels, xmin, xmax, numberOfSamples, samplingTime, 0.5 * samplingTime);

ov_clear (& vorbisFile);
rewind (f);

Expand Down Expand Up @@ -656,7 +656,7 @@ autoSound Sound_readFromOggVorbisFile (MelderFile file) {
} else {
Melder_throw (U"Corrupt header during playback initialization");
}
/*
/*
Clean up this logical bitstream; before exit we see if we're
followed by another [chained]
*/
Expand Down
3 changes: 3 additions & 0 deletions external/vorbis/READ_ME.TXT
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
praat/external/ogg/READ_ME.TXT
David Weenink 22 December 2020
Paul Boersma 16 August 2021
This file describes the adaptations to the libogg-1.3.4 sources and the libvorbis-1.3.7
to make them compilable with the c++ compiler and compatible with Praat.

Expand All @@ -10,3 +11,5 @@ We removed C variable name clashes with C++ defined reserved names new, class an
We changed all .c extensions to .cpp extensions.
We replaced all _ogg_malloc, _ogg_calloc and _ogg_free with _Melder_malloc, _Melder_calloc and Melder_free, respectively,
and added the necessary casting of the void pointer to the resultant type.

In vorbisfile.h, fseek was incorrectly cast to a function taking a 64-bit integer as its second argument. Replaced with fseeko.
2 changes: 1 addition & 1 deletion external/vorbis/vorbisfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ typedef struct {

static ov_callbacks OV_CALLBACKS_NOCLOSE = {
(size_t (*)(void *, size_t, size_t, void *)) fread,
(int (*)(void *, ogg_int64_t, int)) fseek,
(int (*)(void *, ogg_int64_t, int)) fseeko,
(int (*)(void *)) nullptr,
(long (*)(void *)) ftell
};
Expand Down

0 comments on commit c80187c

Please sign in to comment.