Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c747f24

Browse files
committed
CPP: Fix the initialized array case in getBufferSize.
1 parent 628540c commit c747f24

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

cpp/ql/src/semmle/code/cpp/commons/Buffer.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ int getBufferSize(Expr bufferExpr, Element why) {
5858
// buffer is an initialized array
5959
// e.g. int buffer[] = {1, 2, 3};
6060
why = bufferVar.getInitializer().getExpr() and
61+
(
62+
why instanceof AggregateLiteral or
63+
why instanceof StringLiteral
64+
) and
6165
result = why.(Expr).getType().(ArrayType).getSize() and
6266
not exists(bufferVar.getType().getUnspecifiedType().(ArrayType).getSize())
6367
) or exists(Class parentClass, VariableAccess parentPtr |

0 commit comments

Comments
 (0)