Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cpp/ql/src/semmle/code/cpp/dataflow/EscapesTree.qll
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ private predicate valueMayEscapeMutablyAt(Expr e) {
or
t instanceof ReferenceType and
not t.(ReferenceType).getBaseType().isConst()
or
// If the address has been cast to an integral type, conservatively assume that it may eventually be cast back to a
// pointer to non-const type.
t instanceof IntegralType
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,25 @@ int nan2(double x) {
}
}
}

struct info_t {
int id;
unsigned long long value;
};

int command(void* p, unsigned int s);

int callCommand(void)
{
struct info_t info;
unsigned int tmp = 0;

info.id = 1;
info.value = (unsigned long long)& tmp;
if (command(&info, sizeof(info))) {
return 0;
}
if (tmp == 1) // tmp could have been modified by the call.
return 1;
return 0;
}