[PATCH 1/3] d3dx9: Check type and register count for sampler constants.
Paul Gofman
gofmanp at gmail.com
Wed Jun 28 06:28:22 CDT 2017
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
dlls/d3dx9_36/preshader.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx9_36/preshader.c b/dlls/d3dx9_36/preshader.c
index 911ca79..2fb14ab 100644
--- a/dlls/d3dx9_36/preshader.c
+++ b/dlls/d3dx9_36/preshader.c
@@ -654,10 +654,28 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
if (FAILED(hr = get_ctab_constant_desc(ctab, hc, &cdesc[i])))
goto err_out;
inputs_param[i] = get_parameter_by_name(base, NULL, cdesc[i].Name);
+ if (!inputs_param[i])
+ {
+ WARN("Could not find parameter %s in effect.\n", cdesc[i].Name);
+ continue;
+ }
if (cdesc[i].Class == D3DXPC_OBJECT)
+ {
TRACE("Object %s, parameter %p.\n", cdesc[i].Name, inputs_param[i]);
- else if (!inputs_param[i])
- WARN("Could not find parameter %s in effect.\n", cdesc[i].Name);
+ if (cdesc[i].RegisterSet != D3DXRS_SAMPLER || inputs_param[i]->class != D3DXPC_OBJECT
+ || !is_param_type_sampler(inputs_param[i]->type))
+ {
+ WARN("Unexpected object type, constant %s.\n", debugstr_a(cdesc[i].Name));
+ hr = D3DERR_INVALIDCALL;
+ goto err_out;
+ }
+ if (max(inputs_param[i]->element_count, 1) < cdesc[i].RegisterCount)
+ {
+ WARN("Register count exceeds parameter size, constant %s.\n", debugstr_a(cdesc[i].Name));
+ hr = D3DERR_INVALIDCALL;
+ goto err_out;
+ }
+ }
}
out->input_count = desc.Constants;
out->inputs = cdesc;
--
2.9.4
More information about the wine-patches
mailing list