vgmrips / vgmtools

A collection of tools for the VGM file format
GNU General Public License v2.0
125 stars 18 forks source link

`vgm_tag` fails for UTF-8 tag commands #17

Closed HertzDevil closed 2 years ago

HertzDevil commented 2 years ago

Segmentation fault occurs with a command line such as vgm_tag -AuthorJ:山根ミチル test.vgm. It happens because the default locale is C and mbtowc doesn't recognize UTF-8:

https://github.com/vgmrips/vgmtools/blob/1f8a5ebcf5e2f998123dfdcc7571c44020ed3ea5/vgm_tag.c#L544-L545

Here mbtowc returns -1 on the default locale. A workaround is to add setlocale(LC_ALL, "en_US.utf8"); near the beginning of the main function.

ValleyBell commented 2 years ago

good catch!

It should actually be setlocale(LC_ALL, "");. The empty string makes it use the system's default locale. (especially on Windows that is not UTF-8)

ValleyBell commented 2 years ago

fixed by 177bc44a8aa765d9d4e6246edbb453158395ff02 (enable UTF-8 on Unix) and b2554d5513ac74534e84ce2a559afb6f5a42cc21 (fix segfault)