kakwa / libemf2svg

Microsoft (MS) EMF to SVG conversion library
GNU General Public License v2.0
95 stars 32 forks source link

[Bug] possible SEGFAULT in reverse_utf8() #44

Open albrechtd opened 2 years ago

albrechtd commented 2 years ago

A (half-broken?) EMF file I fed into the lib caused a segfault in function reverse_utf8() due to the argument value of char *in being NULL, which in turn has been caused by calling https://github.com/kakwa/libemf2svg/blob/821a40f857cb429bed52c9b1b4c946fbfaff2f55/src/lib/emf2svg_utils.c#L1399 which fills the local string with NULL.

Trivial fix: perform the call https://github.com/kakwa/libemf2svg/blob/821a40f857cb429bed52c9b1b4c946fbfaff2f55/src/lib/emf2svg_utils.c#L1418 iff ((string != NULL) && (*size_out > 0U)).