diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c index d8395b80d44..7ff77e91848 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -5354,7 +5354,7 @@ static unsigned char *WINAPI NdrBaseTypeMarshall( break; case RPC_FC_ENUM16: /* only 16-bits on the wire, so do a sanity check */ - if (*(UINT *)pMemory > USHRT_MAX) + if (*(UINT *)pMemory > SHRT_MAX) RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE); ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); *(USHORT *)pStubMsg->Buffer = *(UINT *)pMemory; diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c index ec129830179..f64c7668a91 100644 --- a/dlls/rpcrt4/tests/ndr_marshall.c +++ b/dlls/rpcrt4/tests/ndr_marshall.c @@ -418,8 +418,9 @@ static void test_simple_types(void) test_pointer_marshal(fmtstr_up_short, &s, 2, wiredata, 6, NULL, 0, "up_short"); test_pointer_marshal(fmtstr_up_ushort, &s, 2, wiredata, 6, NULL, 0, "up_ushort"); - i = s; + i = 0x7fff; *(void**)wiredata = &i; + *(unsigned short*)(wiredata + sizeof(void*)) = i; test_pointer_marshal(fmtstr_up_enum16, &i, 2, wiredata, 6, NULL, 0, "up_enum16"); l = 0xcafebabe;