Wassimulator / CactusViewer

A small single file image viewer written in C/C++.
BSD 2-Clause "Simplified" License
203 stars 15 forks source link

Fix memory corruption caused by swprintf #41

Closed ghost closed 6 months ago

ghost commented 6 months ago

swprintf requires a destination buffer size like snprintf. This was previously only working by chance because of how MSVC emits variadic functions.

swprintf also automatically appends a null terminator to the output string so there's no reason to add it via the format string.

This was leading to a buffer overflow and occasional heap corruption.

Wassimulator commented 6 months ago

I've been chasing this. thanks!