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
114114 abort();
115115 wchar_t *ret = talloc_array(talloc_ctx, wchar_t, count);
116116 MultiByteToWideChar(CP_UTF8, 0, s, -1, ret, count);
117+ if (count <= 0)
118+ abort();
117119 return ret;
118120 }
119121
@@ -124,6 +126,8 @@ char *mp_to_utf8(void *talloc_ctx, const wchar_t *s) · 4 unmodified lines
124126 abort();
125127 char *ret = talloc_array(talloc_ctx, char, count);
126128 WideCharToMultiByte(CP_UTF8, 0, s, -1, ret, count, NULL, NULL);
129+ if (count <= 0)
130+ abort();
127131 return ret;
128132 }
129133

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