Transform get_utf8() function to use grub_utf16_to_utf8_alloc() helper function to convert strings from UTF-16 to UTF-8.
Signed-off-by: Vitaly Kuzmichev <vitaly.kuzmic...@rtsoft.de> --- grub-core/fs/ntfs.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c index 1bee35e87..9258ea835 100644 --- a/grub-core/fs/ntfs.c +++ b/grub-core/fs/ntfs.c @@ -552,23 +552,7 @@ free_file (struct grub_ntfs_file *mft) static char * get_utf8 (grub_uint8_t *in, grub_size_t len) { - grub_uint8_t *buf; - grub_uint16_t *tmp; - grub_size_t i; - - buf = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1); - tmp = grub_calloc (len, sizeof (tmp[0])); - if (!buf || !tmp) - { - grub_free (buf); - grub_free (tmp); - return NULL; - } - for (i = 0; i < len; i++) - tmp[i] = grub_le_to_cpu16 (grub_get_unaligned16 (in + 2 * i)); - *grub_utf16_to_utf8 (buf, tmp, len, UTF16_CPU) = '\0'; - grub_free (tmp); - return (char *) buf; + return (char *) grub_utf16_to_utf8_alloc (in, len, UTF16_LE); } static int -- 2.34.1 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel