Skip to content

Commit

Permalink
Fix invalid memory allocation check
Browse files Browse the repository at this point in the history
Signed-off-by: Phil Wang <[email protected]>
  • Loading branch information
Phillip-Wang committed Aug 3, 2018
1 parent 7dfcb6b commit 7c84151
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions modules/dsp/NE10_fft.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,16 +363,16 @@ ne10_fft_cfg_float32_t ne10_fft_alloc_c2c_float32_neon (ne10_int32_t nfft)

st = (ne10_fft_cfg_float32_t) NE10_MALLOC (memneeded);

// Only backward FFT is scaled by default.
st->is_forward_scaled = 0;
st->is_backward_scaled = 1;

// Bad allocation.
if (st == NULL)
{
return NULL;
}

// Only backward FFT is scaled by default.
st->is_forward_scaled = 0;
st->is_backward_scaled = 1;

uintptr_t address = (uintptr_t) st + sizeof (ne10_fft_state_float32_t);
NE10_BYTE_ALIGNMENT (address, NE10_FFT_BYTE_ALIGNMENT);
st->factors = (ne10_int32_t*) address;
Expand Down
8 changes: 4 additions & 4 deletions modules/dsp/NE10_fft_float32.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,15 +836,15 @@ ne10_fft_cfg_float32_t ne10_fft_alloc_c2c_float32_c (ne10_int32_t nfft)

st = (ne10_fft_cfg_float32_t) NE10_MALLOC (memneeded);

// Only backward FFT is scaled by default.
st->is_forward_scaled = 0;
st->is_backward_scaled = 1;

if (st == NULL)
{
return st;
}

// Only backward FFT is scaled by default.
st->is_forward_scaled = 0;
st->is_backward_scaled = 1;

uintptr_t address = (uintptr_t) st + sizeof (ne10_fft_state_float32_t);
NE10_BYTE_ALIGNMENT (address, NE10_FFT_BYTE_ALIGNMENT);
st->factors = (ne10_int32_t*) address;
Expand Down

0 comments on commit 7c84151

Please sign in to comment.