History

osdep/io: harden string conversions

We already abort if initial call fails, so there is no reason to not to the same, even if we fully expect it wouldn't fail at this point.

Kacper Michajłow committed 1 year ago

Commit fc2f1761 parent 2e0cced1 file · +4 −0Browse files

Unified · Split

osdep/io.c+4−0
@@ -114,6 +114,8 @@ wchar_t *mp_from_utf8(void *talloc_ctx, const char *s) · 113 unmodified lines
114 abort();114 abort();
115 wchar_t *ret = talloc_array(talloc_ctx, wchar_t, count);115 wchar_t *ret = talloc_array(talloc_ctx, wchar_t, count);
116 MultiByteToWideChar(CP_UTF8, 0, s, -1, ret, count);116 MultiByteToWideChar(CP_UTF8, 0, s, -1, ret, count);
117 if (count <= 0)
118 abort();
117 return ret;119 return ret;
118}120}
119 121
@@ -124,6 +126,8 @@ char *mp_to_utf8(void *talloc_ctx, const wchar_t *s) · 4 unmodified lines
124 abort();126 abort();
125 char *ret = talloc_array(talloc_ctx, char, count);127 char *ret = talloc_array(talloc_ctx, char, count);
126 WideCharToMultiByte(CP_UTF8, 0, s, -1, ret, count, NULL, NULL);128 WideCharToMultiByte(CP_UTF8, 0, s, -1, ret, count, NULL, NULL);
129 if (count <= 0)
130 abort();
127 return ret;131 return ret;
128}132}
129 133

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t