Skip to content

Commit adcc48b

Browse files
committed
Simplify error handling of string conversion
Unconditionally free heap-allocated buffer, and only set thread description if MultiByteToWideChar returns a non-zero integer.
1 parent 9d76b17 commit adcc48b

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/queue.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,11 @@ void _dispatch_win32_set_thread_description(HANDLE hThread, const char *descript
4242
}
4343

4444
int result = MultiByteToWideChar(CP_UTF8, 0, description, -1, wcstr, wcsize);
45-
if (result == 0) {
46-
free(wcstr);
47-
return;
48-
}
49-
50-
if (likely(wcstr != NULL)) {
45+
if (result != 0) {
5146
SetThreadDescription(hThread, wcstr);
52-
free(wcstr);
5347
}
48+
49+
free(wcstr);
5450
}
5551
#endif
5652

0 commit comments

Comments
 (0)