Polyspace Bug Finder : MISRA 2012: D 4.14 Rule Violation : Dereferenced pointer is from an unsecure source. Pointer may be NULL or may point to unknown memory.

20 ビュー (過去 30 日間)
Ankita
Ankita 2024 年 1 月 31 日
回答済み: Kausthub 2024 年 3 月 16 日
I have Autogenerated code and I am executing Polyspace Bug Finder MISRA 2012 checks on my source code.
The Warning that i got,
Dereference of parameter (pointer to float 32, size: 32 bits):
Pointer may be null.
Points to 4 bytes at unknown offset in buffer of unknown size, so may be outside bounds.
Pointer may point to dynamically allocated memory.
Can any one help to understand the meaning of MISRA 2012 D4.14 violation?

回答 (1 件)

Kausthub
Kausthub 2024 年 3 月 16 日
Hi Ankita,
MISRA C:2012 Dir 4.14 states that "The validity of values received from external sources shall be checked" and the rationale behined this rule is that the values originating from external sources could be invalid because of errors or deliberate modification by attackers. In short it enforces us to check the data for validity before using it. Documentation suggests that "to reduce this violation, in your MATLAB code, check the validity of values that "coder.ceval" returns."
You could refer to the documenation on this rule which elaborately explains why this violation might happen and how to resolve or fix them: https://www.mathworks.com/help/bugfinder/ref/misrac2012dir4.14.html
Looking at the warning messages that you have provided it looks a possible NULL pointer violation.[might be some other reason as well]
If none works, as a final attempt, [from the documentation] it looks like MISRA C:2012 Dir 4.14 violation is only possible from MATLAB Coder and if this violation occurs in the code generated from Embedded Coder or if you need more help you could connect with the MathWorks Technical Support:
Hope this helps!

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by