Skip to content

Commit

Permalink
[CRT] Fix parameter check for _memicmp on NT 6+
Browse files Browse the repository at this point in the history
Fixes a crash in msvcrt_winetest:string
  • Loading branch information
tkreuzer committed Oct 8, 2023
1 parent b33a199 commit 5a17b5e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sdk/lib/crt/mem/memicmp.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <precomp.h>
#include <compat_undoc.h>

/*
* @implemented
Expand All @@ -8,6 +9,16 @@ int
CDECL
_memicmp(const void *s1, const void *s2, size_t n)
{
if (NtCurrentPeb()->OSMajorVersion >= 6)
{
if (!s1 || !s2)
{
if (n)
MSVCRT_INVALID_PMT(NULL, EINVAL);
return n ? _NLSCMPERROR : 0;
}
}

if (n != 0)
{
const unsigned char *p1 = s1, *p2 = s2;
Expand Down

0 comments on commit 5a17b5e

Please sign in to comment.