Fixed use after free bug.

This commit is contained in:
Mictronics 2017-02-22 15:39:09 +01:00
parent effca83150
commit 630136a1eb

View file

@ -223,10 +223,10 @@ bool rtlsdrOpen(void) {
if (closest == -1 || abs(gains[i] - target) < abs(gains[closest] - target)) if (closest == -1 || abs(gains[i] - target) < abs(gains[closest] - target))
closest = i; closest = i;
} }
rtlsdr_set_tuner_gain(RTLSDR.dev, gains[closest]);
free(gains); free(gains);
rtlsdr_set_tuner_gain(RTLSDR.dev, gains[closest]);
fprintf(stderr, "rtlsdr: tuner gain set to %.1f dB\n", fprintf(stderr, "rtlsdr: tuner gain set to %.1f dB\n",
rtlsdr_get_tuner_gain(RTLSDR.dev)/10.0); rtlsdr_get_tuner_gain(RTLSDR.dev)/10.0);
} }