generated from ossf/project-template
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: David A. Wheeler <[email protected]>
- Loading branch information
1 parent
c2466e4
commit f74f21c
Showing
2 changed files
with
58 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
info = | ||
{ | ||
hints: [ | ||
{ | ||
present: String.raw`\s*free[^;]*; asprintf`, | ||
text: "Do not free the input first, you need to use it.", | ||
examples: [ | ||
[ | ||
"free(s);\nasprintf(&result, \"pre_%s_post\", s);" | ||
] | ||
] | ||
}, | ||
{ | ||
present: String.raw`\s* asprintf \(`, | ||
absent: "free", | ||
text: "This fails to free the memory, likely leading to a missing release.", | ||
examples: [ | ||
[ | ||
"asprintf(&result, \"\"pre_%s_post\"\", s);" | ||
] | ||
] | ||
}, | ||
{ | ||
absent: "return", | ||
text: "This fails to return the result." | ||
}, | ||
{ | ||
absent: String.raw`\s* [^;]+;[^;]+;[^;]+; \s*`, | ||
text: "There should be 3 statements, each terminated with a semicolon.", | ||
examples: [ | ||
[ | ||
"asprintf(&result, \"pre_%s_post\", s);\nfree(s);\nreturn result" | ||
] | ||
] | ||
}, | ||
{ | ||
present: String.raw`\s* return result ; free \s*`, | ||
text: "Do not do anything after the return, it will not execute.", | ||
examples: [ | ||
[ | ||
"asprintf(&result, \"pre_%s_post\", s);\nreturn result;\nfree(s);" | ||
] | ||
] | ||
} | ||
], | ||
expected: [ | ||
` asprintf(&result, "pre_%s_post", s); | ||
free(s); | ||
return result;` | ||
], | ||
correct: [ | ||
String.raw`\s* | ||
asprintf \( & result , "pre_%s_post" , s \) ; | ||
free \( s \) ; | ||
return result ; \s*` | ||
], | ||
} |