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

Commitdde2c76

Browse files
authored
StreamConstPtr: disallow passing a String temporary (#8410)
* StreamConstPtr: prevent from passing a temporary String instance* unconditionally allow progmem chars* missing virtual destructor in Stream(warning: deleting object of abstract class type 'Stream' which has non-virtual destructor will cause undefined behavior [-Wdelete-non-virtual-dtor])
1 parente3c79de commitdde2c76

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

‎cores/esp8266/Stream.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Stream: public Print {
6161
virtualintpeek() = 0;
6262

6363
Stream() {}
64+
virtual~Stream() {}
6465

6566
// parsing methods
6667

‎cores/esp8266/StreamDev.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class StreamConstPtr: public StreamNull
160160
size_t _peekPointer =0;
161161

162162
public:
163+
StreamConstPtr(const String&& string) =delete;// prevents passing String temporary, use ctor(buffer,size) if you know what you are doing
163164
StreamConstPtr(const String& string): _buffer(string.c_str()), _size(string.length()), _byteAddressable(true) { }
164165
StreamConstPtr(constchar* buffer,size_t size): _buffer(buffer), _size(size), _byteAddressable(__byteAddressable(buffer)) { }
165166
StreamConstPtr(constuint8_t* buffer,size_t size): _buffer((constchar*)buffer), _size(size), _byteAddressable(__byteAddressable(buffer)) { }

‎cores/esp8266/StreamSend.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ Stream& operator << (Stream& out, Stream& stream)
341341

342342
Stream&operator << (Stream& out,constchar* text)
343343
{
344-
StreamConstPtr(text).sendAll(out);
344+
StreamConstPtr(text,strlen_P(text)).sendAll(out);
345345
return out;
346346
}
347347

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp