Skip to content

Commit 1b53faf

Browse files
author
Sriya Pratipati
committed
[libc] Reland wchar string conversion mb to wchar
Added crash on nullptr to mbstowcs
1 parent 04b84cb commit 1b53faf

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

libc/src/wchar/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ add_entrypoint_object(
195195
libc.hdr.types.wchar_t
196196
libc.src.__support.common
197197
libc.src.__support.macros.config
198+
libc.src.__support.macros.null_check
198199
libc.src.__support.libc_errno
199200
libc.src.__support.wchar.mbstate
200201
libc.src.__support.wchar.mbsnrtowcs

libc/src/wchar/mbstowcs.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "src/__support/common.h"
1414
#include "src/__support/libc_errno.h"
1515
#include "src/__support/macros/config.h"
16+
#include "src/__support/macros/null_check.h"
1617
#include "src/__support/wchar/mbsnrtowcs.h"
1718
#include "src/__support/wchar/mbstate.h"
1819

@@ -21,6 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
2122
LLVM_LIBC_FUNCTION(size_t, mbstowcs,
2223
(wchar_t *__restrict pwcs, const char *__restrict s,
2324
size_t n)) {
25+
LIBC_CRASH_ON_NULLPTR(s);
2426
// If destination is null, ignore n
2527
n = pwcs == nullptr ? SIZE_MAX : n;
2628
static internal::mbstate internal_mbstate;

0 commit comments

Comments
 (0)