8000 Return 0 and print warning when size() overflows · esp8266/Arduino@909a93f · GitHub
[go: up one dir, main page]

Skip to content

Commit 909a93f

Browse files
Return 0 and print warning when size() overflows
1 parent b4d9834 commit 909a93f

File tree

1 file changed

+6
-1
lines changed
  • libraries/SD/src

1 file changed

+6
-1
lines changed

libraries/SD/src/SD.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ class SDClass {
117117

118118
size_t size() {
119119
uint64_t sz = size64();
120-
return (size_t)std::min( (uint64_t)SIZE_MAX, sz );
120+
if (sz > (uint64_t)SIZE_MAX) {
121+
Serial.printf_P(PSTR("WARNING: SD card size overflow (>= 4GB). Please update source to use size64(). Returning 0.\n"));
122+
return 0;
123+
} else {
124+
return sz;
125+
}
121126
}
122127

123128
uint64_t size64() {

0 commit comments

Comments
 (0)
0