Skip to content

Commit 294fb63

Browse files
jgu222sys_zuul
authored andcommitted
Fixed nullptr dereferencing and reading uninitialized vars.
Change-Id: I5f8c36969c9341a49e07006ea4154d00d0c0ef55
1 parent dfe5c2e commit 294fb63

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

visa/VISAKernelImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,9 +1501,10 @@ int VISAKernelImpl::AddAttributeToVarGeneric(CISA_GEN_VAR *decl, const char* var
15011501
attr->nameIndex = addStringPool(std::string(varName));
15021502
attr->isInt = Attributes::isIntNonKernelAttribute(Attributes::getAttributeID(varName));
15031503

1504+
attr->size = (uint8_t)size;
15041505
if (attr->isInt)
15051506
{
1506-
attr->value.intVal = *((int*)val);
1507+
attr->value.intVal = val ? *((int*)val) : 0;
15071508
assert(attr->size <= 4 && "Int attribute has a value of 4 bytes at most!");
15081509
}
15091510
else
@@ -1512,7 +1513,6 @@ int VISAKernelImpl::AddAttributeToVarGeneric(CISA_GEN_VAR *decl, const char* var
15121513
memcpy_s(temp, size, val, size);
15131514
attr->value.stringVal = (char*)temp;
15141515
}
1515-
attr->size = (uint8_t)size;
15161516

15171517
switch(decl->type)
15181518
{

0 commit comments

Comments
 (0)