Skip to content

Commit

Permalink
Ensure file opened successfully when loading sample (LMMS#5816)
Browse files Browse the repository at this point in the history
  • Loading branch information
DomClark authored Dec 3, 2020
1 parent 3c36365 commit 827d44b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/core/SampleBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,10 @@ void SampleBuffer::update( bool _keep_settings )
{
// Use QFile to handle unicode file names on Windows
QFile f(file);
f.open(QIODevice::ReadOnly);
SNDFILE * snd_file;
SF_INFO sf_info;
sf_info.format = 0;
if( ( snd_file = sf_open_fd( f.handle(), SFM_READ, &sf_info, false ) ) != NULL )
if (f.open(QIODevice::ReadOnly) && (snd_file = sf_open_fd(f.handle(), SFM_READ, &sf_info, false)))
{
f_cnt_t frames = sf_info.frames;
int rate = sf_info.samplerate;
Expand Down Expand Up @@ -396,8 +395,7 @@ f_cnt_t SampleBuffer::decodeSampleSF(QString _f,

// Use QFile to handle unicode file names on Windows
QFile f(_f);
f.open(QIODevice::ReadOnly);
if( ( snd_file = sf_open_fd( f.handle(), SFM_READ, &sf_info, false ) ) != NULL )
if (f.open(QIODevice::ReadOnly) && (snd_file = sf_open_fd(f.handle(), SFM_READ, &sf_info, false)))
{
frames = sf_info.frames;

Expand Down

0 comments on commit 827d44b

Please sign in to comment.