diff --git a/libs/libc/stream/lib_blkoutstream.c b/libs/libc/stream/lib_blkoutstream.c index 4b4bfa90fe7..0126f47cb3b 100644 --- a/libs/libc/stream/lib_blkoutstream.c +++ b/libs/libc/stream/lib_blkoutstream.c @@ -104,6 +104,11 @@ static int blkoutstream_puts(FAR struct lib_outstream_s *self, } else if (remain < sectorsize) { + /* Set content to all 0 before caching, + * so no random content will be flushed + */ + + memset(stream->cache, 0, sectorsize); memcpy(stream->cache, ptr, remain); self->nput += remain; remain = 0; diff --git a/libs/libc/stream/lib_mtdoutstream.c b/libs/libc/stream/lib_mtdoutstream.c index 229a78d8dc1..870abc84d4b 100644 --- a/libs/libc/stream/lib_mtdoutstream.c +++ b/libs/libc/stream/lib_mtdoutstream.c @@ -295,7 +295,7 @@ int lib_mtdoutstream_open(FAR struct lib_mtdoutstream_s *stream, if (node->u.i_mtd->write == NULL) #endif { - stream->cache = lib_zalloc(stream->geo.erasesize); + stream->cache = lib_malloc(stream->geo.erasesize); if (stream->cache == NULL) { close_mtddriver(node);