ref: f4b920c44438997d3783c1b4fb734322065f396f
parent: 973fdb48c025322f474deb86ad23c55c3f7b1875
author: lieff <[email protected]>
date: Sat Aug 4 10:35:33 EDT 2018
check info->buffer malloc before use
--- a/minimp3_ex.h
+++ b/minimp3_ex.h
@@ -75,12 +75,13 @@
} while (frame_info.frame_bytes);
if (!samples)
return;
- info->samples = samples*frame_info.channels;
- size_t allocated = (buf_size/frame_info.frame_bytes)*info->samples*2 + MINIMP3_MAX_SAMPLES_PER_FRAME*2;
+ samples *= frame_info.channels;
+ size_t allocated = (buf_size/frame_info.frame_bytes)*samples*2 + MINIMP3_MAX_SAMPLES_PER_FRAME*2;
info->buffer = malloc(allocated);
- memcpy(info->buffer, pcm, info->samples*2);
if (!info->buffer)
return;
+ info->samples = samples;
+ memcpy(info->buffer, pcm, info->samples*2);
/* save info */
info->channels = frame_info.channels;
info->hz = frame_info.hz;