trendlog.c index & instance usage. #1072
Closed
maimomohali
started this conversation in
General
Replies: 1 comment
-
|
Thank you for reporting the problem with the basic trend log example. I made the changes from instance to log_index in [#1074]. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
While reviewing TL_encode_by_time() in the trend log implementation, I noticed something that might cause problems for anyone using non-trivial instance numbering.
Currently, the function does this early on:
log_index = Trend_Log_Instance_To_Index(pRequest->object_instance);
This correctly resolves the object instance to its corresponding zero-based index in the LogInfo/Logs arrays.
However, later in the function there are accesses like:
Logs[pRequest->object_instance][...] instead of Logs[log_index][...] ,
This works fine with the current default implementation ( index == instance )
But if a user changes this mapping .. — for example, starting instances at 1, or using arbitrary instance numbers — they will likely introduce a mapping table (keylist). In that case, indexing Logs with object_instance would no longer be valid, and the code would access the wrong memory. Since we already retrieve log_index earlier in the function, wouldn’t it be safer and more consistent to use Logs[log_index] instead?
Beta Was this translation helpful? Give feedback.
All reactions