<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Sorry for the double post; I received a bounce email the first time so I'm trying again.</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Hello, all. I was running Mesa with Address Sanitizer [1] turned on, and found one place where ASAN pointed out a read-before-initialized problem. In particular, in _mesa_add_parameter, in prog_parameter.c, |values| represents an array holding a variable
number of values. These values get copied out of the array 4 at a time with the COPY_4V macro, however, the array might only contain a single element. In this case, ASAN reports a read-before-initialize because the last 3 of the 4 elements haven't been written
to yet. I was hoping to contribute a patch that will silence this problem that ASAN reports. I'm happy to incorporate any feedback anyone has into this patch.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Myles C. Maxfield</div>
<div><br>
</div>
<div>[1] <a href="https://code.google.com/p/address-sanitizer/">https://code.google.com/p/address-sanitizer/</a></div>
<div><br>
</div>
<div>
<div>diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c</div>
<div>index 2018fa5..63915fb 100644</div>
<div>--- a/src/mesa/program/prog_parameter.c</div>
<div>+++ b/src/mesa/program/prog_parameter.c</div>
<div>@@ -158,7 +158,17 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,</div>
<div> p->DataType = datatype;</div>
<div> p->Flags = flags;</div>
<div> if (values) {</div>
<div>- COPY_4V(paramList->ParameterValues[oldNum + i], values);</div>
<div>+ if (size & 3) {</div>
<div>+ for (j = 0; j < size; j++) {</div>
<div>+ paramList->ParameterValues[oldNum + i][j] = values[j];</div>
<div>+ }</div>
<div>+ /* silence asan */</div>
<div>+ for (j = size; j < 4; j++) {</div>
<div>+ paramList->ParameterValues[oldNum + i][j].f = 0;</div>
<div>+ }</div>
<div>+ } else {</div>
<div>+ COPY_4V(paramList->ParameterValues[oldNum + i], values);</div>
<div>+ }</div>
<div> values += 4;</div>
<div> p->Initialized = GL_TRUE;</div>
<div> }</div>
</div>
<div><br>
</div>
</div>
</div>
</span>
</body>
</html>