Initialize the arrays to the maximum size of the enums and use c++11 initialization to ensure that all values are set to zero (or equivalent).
Details
- Reviewers
mwolff - Group Reviewers
Frameworks - Commits
- R302:af5397635c4f: Avoid an asan runtime error
execute kdialog --getexistingdirectory smb://
before the patch, the following messages from gcc asan are displayed:
kdesrc/frameworks/kiconthemes/src/kiconeffect.cpp:170:51: runtime error: index 3 out of bounds for type 'int [3]'
kdesrc/frameworks/kiconthemes/src/kiconeffect.cpp:172:51: runtime error: index 3 out of bounds for type 'float [3]'
kdesrc/frameworks/kiconthemes/src/kiconeffect.cpp:174:40: runtime error: index 3 out of bounds for type 'bool [3]'
kdesrc/frameworks/kiconthemes/src/kiconeffect.cpp:176:35: runtime error: index 3 out of bounds for type 'int [3]'
kdesrc/frameworks/kiconthemes/src/kiconeffect.cpp:176:74: runtime error: index 3 out of bounds for type 'int [3]'
kdesrc/frameworks/kiconthemes/src/kiconeffect.cpp:180:35: runtime error: index 3 out of bounds for type 'int [3]'
This runtime error is not shown any more.
Diff Detail
- Repository
- R302 KIconThemes
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
src/kiconeffect.cpp | ||
---|---|---|
44–49 | You can use {{}} to all |
src/kiconeffect.cpp | ||
---|---|---|
44 | To what does this initialize the array? |
src/kiconeffect.cpp | ||
---|---|---|
44 | effect: 0 |
src/kiconeffect.cpp | ||
---|---|---|
44 | it may be a good idea to add a comment that links to http://en.cppreference.com/w/cpp/language/zero_initialization to clarify what's happening here |