- added additional check to MmsValue_update for structure size mismatch

pull/21/head
Michael Zillgith 8 years ago
parent c08fe41cbb
commit 15ec6c7a7c

@ -47,21 +47,25 @@ MmsValue_getBitStringByteSize(const MmsValue* self)
return bitStringByteSize(self); return bitStringByteSize(self);
} }
static void static bool
updateStructuredComponent(MmsValue* self, const MmsValue* update) updateStructuredComponent(MmsValue* self, const MmsValue* update)
{ {
int componentCount;
MmsValue** selfValues; MmsValue** selfValues;
MmsValue** updateValues; MmsValue** updateValues;
componentCount = self->value.structure.size; if (self->value.structure.size != update->value.structure.size)
return false;
selfValues = self->value.structure.components; selfValues = self->value.structure.components;
updateValues = update->value.structure.components; updateValues = update->value.structure.components;
int i; int i;
for (i = 0; i < componentCount; i++) { for (i = 0; i < self->value.structure.size; i++) {
MmsValue_update(selfValues[i], updateValues[i]); if (MmsValue_update(selfValues[i], updateValues[i]) == false)
return false;
} }
return true;
} }
MmsValue* MmsValue*
@ -223,7 +227,8 @@ MmsValue_update(MmsValue* self, const MmsValue* update)
switch (self->type) { switch (self->type) {
case MMS_STRUCTURE: case MMS_STRUCTURE:
case MMS_ARRAY: case MMS_ARRAY:
updateStructuredComponent(self, update); if (updateStructuredComponent(self, update) == false)
return false;
break; break;
case MMS_BOOLEAN: case MMS_BOOLEAN:
self->value.boolean = update->value.boolean; self->value.boolean = update->value.boolean;

Loading…
Cancel
Save