mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-12-04 15:49:48 +00:00
Fix spect_data memory leak in SpectFrame::ImportSPC2 when nx is 0.
This commit is contained in:
+21
-13
@@ -256,25 +256,33 @@ int SpectFrame::ImportSPC2(wxInputStream& stream, float &time_acc)
|
|||||||
if(cy.flags & 0x04)
|
if(cy.flags & 0x04)
|
||||||
markers |= 8;
|
markers |= 8;
|
||||||
|
|
||||||
spect_data = new USHORT[nx];
|
if(nx>0)
|
||||||
|
|
||||||
if(spect_data == NULL)
|
|
||||||
{
|
{
|
||||||
wxLogError(_T("Failed to allocate memory"));
|
spect_data = new USHORT[nx];
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
max_y = 0;
|
if(spect_data == NULL)
|
||||||
for(ix=0; ix<nx; ix++)
|
{
|
||||||
{
|
wxLogError(_T("Failed to allocate memory"));
|
||||||
spect_data[ix] = p->data[ix];
|
return(1);
|
||||||
if(spect_data[ix] > max_y)
|
}
|
||||||
max_y = spect_data[ix];
|
|
||||||
|
max_y = 0;
|
||||||
|
for(ix=0; ix<nx; ix++)
|
||||||
|
{
|
||||||
|
spect_data[ix] = p->data[ix];
|
||||||
|
if(spect_data[ix] > max_y)
|
||||||
|
max_y = spect_data[ix];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(nx==0)
|
else
|
||||||
{
|
{
|
||||||
nx = int(8000/dx);
|
nx = int(8000/dx);
|
||||||
spect_data = new USHORT[nx];
|
spect_data = new USHORT[nx];
|
||||||
|
if(spect_data == NULL)
|
||||||
|
{
|
||||||
|
wxLogError(_T("Failed to allocate memory"));
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
for(ix=0; ix<nx; ix++)
|
for(ix=0; ix<nx; ix++)
|
||||||
spect_data[ix] = 1;
|
spect_data[ix] = 1;
|
||||||
max_y = 1;
|
max_y = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user