<p></p>
<p><b>@benpicco</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/RIOT-OS/RIOT/pull/16816#discussion_r703245162">drivers/mtd/mtd.c</a>:</p>
<pre style='color:#555'>> @@ -167,11 +167,16 @@ int mtd_write_page(mtd_dev_t *mtd, const void *data, uint32_t page,
         return res;
     }
 
+    /* prevent heap overflow of work buffer */
+    if (count + offset > sector_size) {
</pre>
<p>Yes you are right. But we should check this <em>before</em> erasing the page.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/16816#discussion_r703245162">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABE7WYAESL23L6LQQGQCUDLUAW4HDANCNFSM5DQQ6U5A">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/ABE7WYA22UTQQLSER2CECHLUAW4HDA5CNFSM5DQQ6U5KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOFSH52II.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/16816#discussion_r703245162",
"url": "https://github.com/RIOT-OS/RIOT/pull/16816#discussion_r703245162",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>