Browse Source

Fix spect_data memory leak in SpectFrame::ImportSPC2 when nx is 0.

master
Reece H. Dunn 9 years ago
parent
commit
7afe4cf0bf
1 changed files with 21 additions and 13 deletions
  1. 21
    13
      src/spect.cpp

+ 21
- 13
src/spect.cpp View File

if(cy.flags & 0x04) if(cy.flags & 0x04)
markers |= 8; markers |= 8;


spect_data = new USHORT[nx];

if(spect_data == NULL)
if(nx>0)
{ {
wxLogError(_T("Failed to allocate memory"));
return(1);
}
spect_data = new USHORT[nx];


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(spect_data == NULL)
{
wxLogError(_T("Failed to allocate memory"));
return(1);
}

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;

Loading…
Cancel
Save