瀏覽代碼

LibC: Specifically clear only stored bytes after successful mbrtowc

Tim Schumacher 3 年之前
父節點
當前提交
212f9308d4
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      Userland/Libraries/LibC/wchar.cpp

+ 2 - 2
Userland/Libraries/LibC/wchar.cpp

@@ -280,8 +280,8 @@ size_t mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t* state)
         *pwc = codepoint;
         *pwc = codepoint;
     }
     }
 
 
-    // We don't have a shift state that we need to keep, so just clear the entire state
-    *state = {};
+    // We want to read the next multibyte character, but keep all other properties.
+    state->stored_bytes = 0;
 
 
     if (codepoint == 0) {
     if (codepoint == 0) {
         return 0;
         return 0;