Skip to content

Commit 88f9078

Browse files
authored
Remove null byte at the end of fdopen's faux filename
1 parent af37520 commit 88f9078

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

platform/mbed_retarget.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,10 @@ void mbed_set_unbuffered_stream(std::FILE *_file) {
827827
std::FILE *mbed_fdopen(FileHandle *fh, const char *mode)
828828
{
829829
// This is to avoid scanf(buf, ":%.4s", fh) and the bloat it brings.
830-
char buf[2 + sizeof(fh) + 1]; /* :(pointer) + null byte */
831-
MBED_STATIC_ASSERT(sizeof(buf) == 7, "Pointers should be 4 bytes.");
830+
char buf[1 + sizeof(fh)]; /* :(pointer) */
831+
MBED_STATIC_ASSERT(sizeof(buf) == 5, "Pointers should be 4 bytes.");
832832
buf[0] = ':';
833833
memcpy(buf + 1, &fh, sizeof(fh));
834-
buf[1 + sizeof(fh)] = '\0';
835834

836835
std::FILE *stream = std::fopen(buf, mode);
837836
/* newlib-nano doesn't appear to ever call _isatty itself, so

0 commit comments

Comments
 (0)