diff options
Diffstat (limited to 'libcrystfel/src/spectrum.c')
-rw-r--r-- | libcrystfel/src/spectrum.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libcrystfel/src/spectrum.c b/libcrystfel/src/spectrum.c index bf38a73a..91bc48c9 100644 --- a/libcrystfel/src/spectrum.c +++ b/libcrystfel/src/spectrum.c @@ -390,9 +390,13 @@ static int read_esrf_spectrum(FILE *fh, Spectrum *s) if ( n_bins == max_bins ) { max_bins += 64; - k = realloc(k, max_bins*sizeof(double)); - samp = realloc(samp, max_bins*sizeof(double)); - if ( (k==NULL) || (samp==NULL) ) return 1; + k = srealloc(k, max_bins*sizeof(double)); + samp = srealloc(samp, max_bins*sizeof(double)); + if ( (k==NULL) || (samp==NULL) ) { + free(k); + free(samp); + return 1; + } } k[n_bins] = ph_eV_to_k(energy*1000.0); |