Cleanup/fix bad code in IDP_SetIndexArray()
Mainly, using index before checking for its validity...
This commit is contained in:
parent
5b3b0b4778
commit
4cfac9edab
|
@ -130,18 +130,22 @@ void IDP_FreeIDPArray(IDProperty *prop)
|
|||
MEM_freeN(prop->data.pointer);
|
||||
}
|
||||
|
||||
/*shallow copies item*/
|
||||
/* shallow copies item */
|
||||
void IDP_SetIndexArray(IDProperty *prop, int index, IDProperty *item)
|
||||
{
|
||||
IDProperty *old;
|
||||
|
||||
BLI_assert(prop->type == IDP_IDPARRAY);
|
||||
|
||||
if (index >= prop->len || index < 0)
|
||||
return;
|
||||
|
||||
old = GETPROP(prop, index);
|
||||
if (index >= prop->len || index < 0) return;
|
||||
if (item != old) IDP_FreeProperty(old);
|
||||
|
||||
memcpy(GETPROP(prop, index), item, sizeof(IDProperty));
|
||||
if (item != old) {
|
||||
IDP_FreeProperty(old);
|
||||
|
||||
memcpy(old, item, sizeof(IDProperty));
|
||||
}
|
||||
}
|
||||
|
||||
IDProperty *IDP_GetIndexArray(IDProperty *prop, int index)
|
||||
|
|
Loading…
Reference in New Issue