Skip to content

Commit

Permalink
Backport memory leak fix for savonet/liquidsoap#1146
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Apr 13, 2020
1 parent f3a54b5 commit 10c4d21
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.1.6 (12-04-2020)
======
* Fix return status for native and ogg read callbacks (savonet/liquidosoap#1146)

0.1.5 (27-06-2019)
=====
* More cleanup.
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# check for one particular file of the sources
AC_INIT([ocaml-flac],[0.1.5],[[email protected]])
AC_INIT([ocaml-flac],[0.1.6],[[email protected]])

VERSION=$PACKAGE_VERSION
AC_MSG_RESULT([configuring $PACKAGE_STRING])
Expand Down
5 changes: 4 additions & 1 deletion src/flac_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,10 @@ static FLAC__StreamDecoderReadStatus dec_read_callback(const FLAC__StreamDecoder

caml_release_runtime_system();

return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
if (len ==0)
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
else
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}

static inline double sample_to_double(FLAC__int32 x, unsigned bps)
Expand Down
6 changes: 5 additions & 1 deletion src/ogg_demuxer_flac_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ let decoder os =
Ogg_flac.Decoder.get_callbacks
(fun ret -> feed ret)
in
Flac.Decoder.process decoder c
match Flac.Decoder.state decoder c with
| `Search_for_metadata | `Read_metadata | `Search_for_frame_sync
| `Read_frame ->
Flac.Decoder.process decoder c
| _ -> raise Ogg.End_of_stream
in
let restart new_os =
os := new_os;
Expand Down
5 changes: 4 additions & 1 deletion src/ogg_flac_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ static FLAC__StreamDecoderReadStatus ogg_read_callback(const FLAC__StreamDecoder
caml_release_runtime_system();

*bytes = len;
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
if (len == 0)
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
else
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}

CAMLprim value ocaml_flac_decoder_ogg_update_os(value v, value os)
Expand Down

0 comments on commit 10c4d21

Please sign in to comment.