Commit eff21067 authored by Max Kellermann's avatar Max Kellermann

mpc: assume the result fo of mpc_decoder_decode() is unsigned

According to the documentation, mpc_decoder_decode() returns an mpc_uint32_t. Since the special return value (mpc_uint32_t)-1 translates to a very large long integer, this may cause segmentation faults if not interpreted properly.
parent 0a6f4048
......@@ -115,7 +115,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
long ret;
mpc_uint32_t ret;
int32_t chunk[G_N_ELEMENTS(sample_buffer)];
long bitRate = 0;
unsigned long samplePos = 0;
......@@ -179,7 +179,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
vbrUpdateBits = 0;
ret = mpc_decoder_decode(&decoder, sample_buffer,
&vbrUpdateAcc, &vbrUpdateBits);
if (ret <= 0)
if (ret == 0 || ret == (mpc_uint32_t)-1)
break;
samplePos += ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment