1
0
Fork 0

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:
Freddie Chopin 2020-05-12 17:24:06 +02:00 committed by GitHub
parent a773713d91
commit 0048cb52c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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];
}