Skip to content

Commit 3d0ba4a

Browse files
committed
Add a check for VideoSnapshot&& to ImageViewRGB32 conversion
1 parent e0b8195 commit 3d0ba4a

1 file changed

Lines changed: 39 additions & 8 deletions

File tree

.github/workflows/cpp-ci-serial-programs-base.yml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
mkdir bin
8787
cd bin
8888
cmake .. -DQT_MAJOR:STRING=6 ${{env.CMAKE_ADDITIONAL_FLAGS}}
89-
cmake --build . --config RelWithDebInfo --parallel 10
89+
# cmake --build . --config RelWithDebInfo --parallel 10
9090
9191
- name: Prepare upload build
9292
if: inputs.upload-build
@@ -132,18 +132,49 @@ jobs:
132132
cd Arduino-Source
133133
134134
cat << 'EOF' > query.txt
135-
set output dump
136-
match invocation(
135+
set output diag
136+
match cxxConstructExpr(
137137
isExpansionInFileMatching("SerialPrograms/"),
138138
hasDeclaration(cxxConstructorDecl(ofClass(hasName("std::filesystem::path")))),
139139
hasArgument(0, hasType(asString("std::string")))
140140
)
141+
142+
# match cxxConstructExpr(
143+
# isExpansionInFileMatching("SerialPrograms/"),
144+
# hasDeclaration(cxxConstructorDecl(ofClass(hasName("ImageViewRGB32")))),
145+
# hasArgument(0, hasType(rValueReferenceType(pointee(hasType(hasName("VideoSnapshot")))))),
146+
# unless(hasAncestor(functionDecl(isInline())))
147+
# )
148+
149+
match cxxConstructExpr(
150+
isExpansionInFileMatching("SerialPrograms/"),
151+
hasDeclaration(cxxConstructorDecl(ofClass(hasName("ImageViewRGB32")))),
152+
hasArgument(0, hasType(asString("VideoSnapshot"))),
153+
unless(hasAncestor(functionDecl(isInline())))
154+
)
141155
EOF
142156
143-
files=$(jq -r '.[].file' SerialPrograms/bin/compile_commands.json)
144-
echo "$files" | xargs --max-args=150 clang-query -p SerialPrograms/bin/ -f query.txt >> output.txt
145-
cat output.txt
146-
if grep --silent "Match #" output.txt; then
147-
echo "::error Forbidden std::filesystem::path construction detected!"
157+
# files=$(jq -r '.[].file' SerialPrograms/bin/compile_commands.json)
158+
# echo "$files" | xargs --max-args=150 clang-query -p SerialPrograms/bin/ -f query.txt >> clang-query_output.txt
159+
clang-query -p SerialPrograms/bin/ /home/runner/work/Arduino-Source/Arduino-Source/Arduino-Source/3rdParty/QtWavFile/WavFile.cpp -f query.txt >> clang-query_output.txt
160+
161+
echo "Clang query output (begin)"
162+
cat clang-query_output.txt
163+
echo "Clang query output (end)"
164+
165+
if grep --silent "Match #" clang-query_output.txt; then
166+
echo "::error Forbidden code detected! It can be one of the following:"
167+
echo "::error - std::filesystem::path created from std::string. More information https://discord.com/channels/695809740428673034/1462210406616531259/1462567541825339635"
168+
echo "::error - ImageViewRGB32 created from VideoSnapshot&& that is stored. It is a dangling pointer as nothing hold the data anymore"
169+
echo "::error You can read more about the exact error with the artifact below."
148170
exit 1
149171
fi
172+
173+
- name: Upload Clang query output
174+
uses: actions/upload-artifact@v7
175+
if: inputs.run-clang-query && always()
176+
with:
177+
name: Clang query output (compiler=${{inputs.compiler}})
178+
path: |
179+
Arduino-Source/SerialPrograms/bin/compile_commands.json
180+
Arduino-Source/clang-query_output.txt

0 commit comments

Comments
 (0)