Fix pointer bug in CO_OD_getFlagsPointer() (#181)
Function did not check whether the object had any flags assigned. It makes no difference for objects with no subindexes, because then the function will return NULL anyway. But is subIndex argument is not zero, then the function calculates addresses of flags as offsets from NULL. For example, for an object with no flags assigned, when subIndex == 5, the function would return 5 as the address instead of the expected NULL.
This commit is contained in:
parent
a773713d91
commit
0048cb52c7
1 changed files with 6 additions and 5 deletions
|
|
@ -451,13 +451,14 @@ void* CO_OD_getDataPointer(CO_SDO_t *SDO, uint16_t entryNo, uint8_t subIndex){
|
|||
|
||||
/******************************************************************************/
|
||||
uint8_t* CO_OD_getFlagsPointer(CO_SDO_t *SDO, uint16_t entryNo, uint8_t subIndex){
|
||||
CO_OD_extension_t* ext;
|
||||
|
||||
if((entryNo == 0xFFFFU) || (SDO->ODExtensions == 0)){
|
||||
return 0;
|
||||
if(entryNo == 0xFFFF || SDO->ODExtensions == NULL){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ext = &SDO->ODExtensions[entryNo];
|
||||
CO_OD_extension_t* ext = &SDO->ODExtensions[entryNo];
|
||||
if (ext->flags == NULL){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &ext->flags[subIndex];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue