Skip to content

Commit

Permalink
crnlib: attempt to silence false positive CodeQL cpp/static-buffer-ov…
Browse files Browse the repository at this point in the history
…erflow

On the default case it wrongly reports as critical:

> Potential buffer-overflow: 'm_buf' has size 2 but 'm_buf[3]' may be accessed here.

Because it fails to understand that default only happens with m_buf size being 4.
  • Loading branch information
illwieckz committed Jul 6, 2024
1 parent a4f81a6 commit c83c921
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crnlib/crn_packed_uint.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct packed_uint {
}

inline operator unsigned int() const {
switch (N) {
switch (sizeof(m_buf)) {
case 1:
return m_buf[0];
case 2:
Expand Down
2 changes: 1 addition & 1 deletion inc/crn_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ struct crn_packed_uint {
}

inline operator unsigned int() const {
switch (N) {
switch (sizeof(m_buf)) {
case 1:
return m_buf[0];
case 2:
Expand Down

0 comments on commit c83c921

Please sign in to comment.