diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 151d266f4b..6d44f32d7b 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -592,7 +592,7 @@ static inline WCHAR *heap_strdupAtoW(const char *str)
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
ret = heap_alloc(len*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, str, -1, ret, -1);
+ MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
}
return ret;