Skip to content

Comments

BUG: specfun/specfun.h: initialize kd in mtu12 to fix potential uninitialized use#91

Open
stratakis wants to merge 1 commit intoscipy:mainfrom
stratakis:kd_uninit
Open

BUG: specfun/specfun.h: initialize kd in mtu12 to fix potential uninitialized use#91
stratakis wants to merge 1 commit intoscipy:mainfrom
stratakis:kd_uninit

Conversation

@stratakis
Copy link
Contributor

The kd variable was not initialized before the kf==1/kf==2 conditional blocks. If kf had an unexpected value, kd would be used uninitialized when passed to cva2(). Initialize to 0 for consistency with mtu0.

Uncovered by Coverity static analysis.

…tialized use

The kd variable was not initialized before the kf==1/kf==2 conditional
blocks. If kf had an unexpected value, kd would be used uninitialized
when passed to cva2(). Initialize to 0 for consistency with mtu0.

Uncovered by Coverity static analysis.
@stratakis
Copy link
Contributor Author

This is not trigerrable with the current callers as kf will always be 1 or 2. However mtu12() is a public template function and future callers could potentially pass invalid values.

Coverity message
1. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:4762:9: var_decl: Declaring variable "kd" without initializer.
2. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:4764:9: path: Condition "kf == 1", taking false branch.
3. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:4767:9: path: Condition "kf == 1", taking false branch.
4. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:4770:9: path: Condition "kf == 2", taking false branch.
5. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:4773:9: path: Condition "kf == 2", taking false branch.
**6. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:4777:9: uninit_use_in_call: Using uninitialized value "kd" when calling "cva2".**
7. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1737:9: path: Condition "m <= 12", taking true branch.
8. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1738:13: read_value: Reading value "kd" when calling "cv0".
9. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1590:9: path: Condition "m == 0", taking true branch.
10. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1591:13: path: Condition "q <= 1.", taking false branch.
11. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1593:20: path: Condition "q <= 10.", taking false branch.
12. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1596:17: read_value: Reading value "kd" when calling "cvql".
13. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1866:9: read_value: Reading value "kd".
14. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1866:9: path: Condition "kd == 1", taking true branch.
15. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1869:9: path: Condition "kd == 3", taking false branch.
16. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1869:9: path: Condition "kd == 4", taking false branch.
17. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1598:9: path: Falling through to end of if statement.
18. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1739:13: path: Condition "q != 0.", taking true branch.
19. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1739:13: path: Condition "m != 2", taking true branch.
20. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1742:13: path: Condition "q > 0.002", taking true branch.
21. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1742:13: path: Condition "m == 2", taking false branch.
22. scipy-1.16.2/subprojects/xsf/include/xsf/specfun/specfun.h:1745:9: path: Falling through to end of if statement.
# 4775| }
# 4776|
# 4777|-> a = cva2(kd, m, q);
# 4778|
# 4779| if (q <= 1.0) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant