mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2024-12-25 02:18:29 +01:00
rtlsdr_set_sample_rate(): don't access dev structure before checking for NULL
Thanks to Derek Lieber for reporting this bug. Signed-off-by: Steve Markgraf <steve@steve-m.de>
This commit is contained in:
parent
314683a51e
commit
4b057fea0f
@ -965,7 +965,6 @@ int rtlsdr_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate)
|
||||
uint16_t tmp;
|
||||
uint32_t rsamp_ratio;
|
||||
double real_rate;
|
||||
uint32_t rtl_freq = dev->rtl_xtal;
|
||||
|
||||
if (!dev)
|
||||
return -1;
|
||||
@ -974,10 +973,10 @@ int rtlsdr_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate)
|
||||
if (samp_rate > MAX_SAMP_RATE)
|
||||
samp_rate = MAX_SAMP_RATE;
|
||||
|
||||
rsamp_ratio = (rtl_freq * TWO_POW(22)) / samp_rate;
|
||||
rsamp_ratio = (dev->rtl_xtal * TWO_POW(22)) / samp_rate;
|
||||
rsamp_ratio &= ~3;
|
||||
|
||||
real_rate = (rtl_freq * TWO_POW(22)) / rsamp_ratio;
|
||||
real_rate = (dev->rtl_xtal * TWO_POW(22)) / rsamp_ratio;
|
||||
|
||||
if ( ((double)samp_rate) != real_rate )
|
||||
fprintf(stderr, "Exact sample rate is: %f Hz\n", real_rate);
|
||||
|
Loading…
Reference in New Issue
Block a user