Skip to content

Commit f55df64

Browse files
committed
CopyEncoder: prevent NPE
1 parent 7d5595b commit f55df64

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/AudioTools/AudioCodecs/CodecCopy.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ class CopyEncoder : public AudioEncoder {
7979

8080
void end() {}
8181

82-
size_t write(const uint8_t *data, size_t len) { return pt_print->write((uint8_t*)data,len); }
82+
size_t write(const uint8_t *data, size_t len) {
83+
if (pt_print == nullptr) {
84+
LOGE("No output stream defined for CopyDecoder");
85+
return 0;
86+
}
87+
return pt_print->write((uint8_t*)data,len);
88+
}
8389

8490
operator bool() { return true; }
8591

0 commit comments

Comments
 (0)