Browse Source

fix wrong write and read in not allocated memory

pre-master-46
dwarning 9 years ago
parent
commit
2377d3a64f
  1. 7
      src/frontend/com_fft.c
  2. 2
      src/frontend/trannoise/1-f-code.c

7
src/frontend/com_fft.c

@ -355,11 +355,10 @@ com_psd(wordlist *wl)
vec_new(f); vec_new(f);
freq = f->v_realdata; freq = f->v_realdata;
for (i = 0; i < fpts; i++)
#ifdef HAVE_LIBFFTW3 #ifdef HAVE_LIBFFTW3
for (i = 0; i <= fpts; i++)
freq[i] = i*1./span; freq[i] = i*1./span;
#else #else
for (i = 0; i <= fpts; i++)
freq[i] = i*1./span*length/N; freq[i] = i*1./span*length/N;
#endif #endif
@ -449,7 +448,7 @@ com_psd(wordlist *wl)
#endif #endif
printf("Total noise power up to Nyquist frequency %5.3e Hz:\n%e V^2 (or A^2), \nnoise voltage or current %e V (or A)\n", printf("Total noise power up to Nyquist frequency %5.3e Hz:\n%e V^2 (or A^2), \nnoise voltage or current %e V (or A)\n",
freq[fpts], noipower, sqrt(noipower));
freq[fpts-1], noipower, sqrt(noipower));
/* smoothing with rectangular window of width "smooth", /* smoothing with rectangular window of width "smooth",
plotting V/sqrt(Hz) or I/sqrt(Hz) */ plotting V/sqrt(Hz) or I/sqrt(Hz) */
@ -473,7 +472,7 @@ com_psd(wordlist *wl)
} }
for (j = fpts-hsmooth; j < fpts; j++) { for (j = fpts-hsmooth; j < fpts; j++) {
sum = 0.; sum = 0.;
for (jj = 0; jj < smooth; jj++)
for (jj = 0; jj < hsmooth; jj++)
sum += fdvec[i][j-hsmooth+jj].cx_real; sum += fdvec[i][j-hsmooth+jj].cx_real;
sum /= (fpts - j + hsmooth - 1); sum /= (fpts - j + hsmooth - 1);
reald[j] = (sqrt(sum)/scaling); reald[j] = (sqrt(sum)/scaling);

2
src/frontend/trannoise/1-f-code.c

@ -37,7 +37,7 @@ f_alpha(int n_pts, int n_exp, double X[], double Q_d, double alpha)
ha = alpha/2.0; ha = alpha/2.0;
// Q_d = sqrt(Q_d); /* find the deviation of the noise */ // Q_d = sqrt(Q_d); /* find the deviation of the noise */
#ifdef HAVE_LIBFFTW3 #ifdef HAVE_LIBFFTW3
length = 2 * (n_pts/2 + 1);
length = n_pts + 2;
#else #else
length = n_pts; length = n_pts;
#endif #endif

Loading…
Cancel
Save