Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit90ce6f1

Browse files
committed
Avoid crashes when .available() is called by detecting that underlying stream has closed.
1 parent02cfb98 commit90ce6f1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

‎src/Firebase.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,15 @@ FirebaseStream::FirebaseStream(const std::string& host, const std::string& auth,
193193
}
194194

195195
boolFirebaseStream::available() {
196-
return http_->getStreamPtr()->available();
196+
auto client = http_->getStreamPtr();
197+
return (client ==nullptr) ?false : client->available();
197198
}
198199

199200
FirebaseStream::EventFirebaseStream::read(std::string& event) {
200201
auto client = http_->getStreamPtr();
202+
if (client ==nullptr) {
203+
returnEvent();
204+
}
201205
Event type;
202206
std::string typeStr = client->readStringUntil('\n').substring(7).c_str();
203207
if (typeStr =="put") {

‎src/FirebaseArduino.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,15 @@ void FirebaseArduino::stream(const String& path) {
131131
}
132132

133133
boolFirebaseArduino::available() {
134-
return http_->getStreamPtr()->available();
134+
auto client = http_->getStreamPtr();
135+
return (client ==nullptr) ?false : client->available();
135136
}
136137

137138
FirebaseObjectFirebaseArduino::readEvent() {
138139
auto client = http_->getStreamPtr();
140+
if (client ==nullptr) {
141+
returnFirebaseObject("");
142+
}
139143
String type = client->readStringUntil('\n').substring(7);;
140144
String event = client->readStringUntil('\n').substring(6);
141145
client->readStringUntil('\n');// consume separator

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp