Skip to content

Commit 494c127

Browse files
committed
AudioSourceURL: npe
1 parent fa22803 commit 494c127

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/AudioTools/Disk/AudioSourceURL.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class AudioSourceURL : public AudioSource {
4646

4747
/// Opens the selected url from the array
4848
Stream* selectStream(int idx) override {
49+
if (size()==0) return nullptr;
4950
pos = idx;
5051
if (pos < 0) {
5152
pos = 0;
@@ -57,7 +58,9 @@ class AudioSourceURL : public AudioSource {
5758
}
5859
LOGI("selectStream: %d/%d -> %s", pos, size() - 1, value(pos));
5960
if (started) actual_stream->end();
60-
actual_stream->begin(value(pos), mime);
61+
const char* url = value(pos);
62+
if (url == nullptr) return nullptr;
63+
actual_stream->begin(url, mime);
6164
started = true;
6265
return actual_stream;
6366
}
@@ -121,7 +124,7 @@ class AudioSourceURL : public AudioSource {
121124
AudioSourceURL() = default;
122125

123126
virtual const char* value(int pos) {
124-
if (urlArray == nullptr) return nullptr;
127+
if (urlArray == nullptr || size()==0) return nullptr;
125128
return urlArray[pos];
126129
}
127130

0 commit comments

Comments
 (0)