mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-03 02:36:11 +00:00
fix(screenshot): drop C-style cast UB, fix ERR check order
handleScreenshotRequest() reinterpret-cast every DisplayDriver* first to SH1106Display* then to SSD1306Display*; both casts always produce a non-null pointer, so the SSD1306 fallback was unreachable and on any SSD1306 build we called SH1106::getBuffer() on a SSD1306 object — UB that only happened to work because both backing classes share an Adafruit_GFX layout at offset zero. Replace the cast hack with virtual getBuffer()/getBufferSize() on DisplayDriver, overridden in SH1106Display and SSD1306Display. MyMesh no longer needs to know about either concrete type. const-correct the buffer pointer and widen bufferSize to uint16_t while passing through. Also fix the matching Python decoder: it sanity-checked length before dispatching on resp_code, so a 2-byte RESP_CODE_ERR frame was reported as "Frame too short" instead of the actual device error. Move the length check after the resp_code dispatch and log the error code byte. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -229,7 +229,7 @@ private:
|
||||
bool isValidClientRepeatFreq(uint32_t f) const;
|
||||
#ifdef ENABLE_SCREENSHOT
|
||||
void handleScreenshotRequest();
|
||||
void sendScreenshotResponse(DisplayDriver* display, uint8_t* buffer, int bufferSize);
|
||||
void sendScreenshotResponse(DisplayDriver* display, const uint8_t* buffer, uint16_t bufferSize);
|
||||
#endif
|
||||
|
||||
UITask* getUITask() { return (UITask*)_ui; }
|
||||
|
||||
Reference in New Issue
Block a user