mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Test no result if deferred function returns error
This commit is contained in:
@@ -6,14 +6,14 @@ edges
|
||||
| tests.go:31:5:31:78 | ... := ...[0] | tests.go:33:29:33:29 | f |
|
||||
| tests.go:32:21:32:21 | f | tests.go:8:24:8:24 | definition of f |
|
||||
| tests.go:33:29:33:29 | f | tests.go:12:32:12:32 | definition of f |
|
||||
| tests.go:43:5:43:76 | ... := ...[0] | tests.go:44:21:44:21 | f |
|
||||
| tests.go:43:5:43:76 | ... := ...[0] | tests.go:45:29:45:29 | f |
|
||||
| tests.go:44:21:44:21 | f | tests.go:8:24:8:24 | definition of f |
|
||||
| tests.go:45:29:45:29 | f | tests.go:12:32:12:32 | definition of f |
|
||||
| tests.go:51:5:51:78 | ... := ...[0] | tests.go:53:3:53:3 | f |
|
||||
| tests.go:63:5:63:76 | ... := ...[0] | tests.go:65:3:65:3 | f |
|
||||
| tests.go:105:5:105:78 | ... := ...[0] | tests.go:107:9:107:9 | f |
|
||||
| tests.go:122:5:122:78 | ... := ...[0] | tests.go:126:3:126:3 | f |
|
||||
| tests.go:45:5:45:76 | ... := ...[0] | tests.go:46:21:46:21 | f |
|
||||
| tests.go:45:5:45:76 | ... := ...[0] | tests.go:47:29:47:29 | f |
|
||||
| tests.go:46:21:46:21 | f | tests.go:8:24:8:24 | definition of f |
|
||||
| tests.go:47:29:47:29 | f | tests.go:12:32:12:32 | definition of f |
|
||||
| tests.go:54:5:54:78 | ... := ...[0] | tests.go:56:3:56:3 | f |
|
||||
| tests.go:66:5:66:76 | ... := ...[0] | tests.go:68:3:68:3 | f |
|
||||
| tests.go:108:5:108:78 | ... := ...[0] | tests.go:110:9:110:9 | f |
|
||||
| tests.go:125:5:125:78 | ... := ...[0] | tests.go:129:3:129:3 | f |
|
||||
nodes
|
||||
| tests.go:8:24:8:24 | definition of f | semmle.label | definition of f |
|
||||
| tests.go:9:8:9:8 | f | semmle.label | f |
|
||||
@@ -23,24 +23,24 @@ nodes
|
||||
| tests.go:31:5:31:78 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:32:21:32:21 | f | semmle.label | f |
|
||||
| tests.go:33:29:33:29 | f | semmle.label | f |
|
||||
| tests.go:43:5:43:76 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:44:21:44:21 | f | semmle.label | f |
|
||||
| tests.go:45:29:45:29 | f | semmle.label | f |
|
||||
| tests.go:51:5:51:78 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:53:3:53:3 | f | semmle.label | f |
|
||||
| tests.go:63:5:63:76 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:65:3:65:3 | f | semmle.label | f |
|
||||
| tests.go:105:5:105:78 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:107:9:107:9 | f | semmle.label | f |
|
||||
| tests.go:122:5:122:78 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:126:3:126:3 | f | semmle.label | f |
|
||||
| tests.go:45:5:45:76 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:46:21:46:21 | f | semmle.label | f |
|
||||
| tests.go:47:29:47:29 | f | semmle.label | f |
|
||||
| tests.go:54:5:54:78 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:56:3:56:3 | f | semmle.label | f |
|
||||
| tests.go:66:5:66:76 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:68:3:68:3 | f | semmle.label | f |
|
||||
| tests.go:108:5:108:78 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:110:9:110:9 | f | semmle.label | f |
|
||||
| tests.go:125:5:125:78 | ... := ...[0] | semmle.label | ... := ...[0] |
|
||||
| tests.go:129:3:129:3 | f | semmle.label | f |
|
||||
subpaths
|
||||
#select
|
||||
| tests.go:9:8:9:8 | f | tests.go:31:5:31:78 | ... := ...[0] | tests.go:9:8:9:8 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:31:15:31:78 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:9:8:9:8 | f | tests.go:43:5:43:76 | ... := ...[0] | tests.go:9:8:9:8 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:43:15:43:76 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:9:8:9:8 | f | tests.go:45:5:45:76 | ... := ...[0] | tests.go:9:8:9:8 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:45:15:45:76 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:14:3:14:3 | f | tests.go:31:5:31:78 | ... := ...[0] | tests.go:14:3:14:3 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:31:15:31:78 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:14:3:14:3 | f | tests.go:43:5:43:76 | ... := ...[0] | tests.go:14:3:14:3 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:43:15:43:76 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:53:3:53:3 | f | tests.go:51:5:51:78 | ... := ...[0] | tests.go:53:3:53:3 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:51:15:51:78 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:65:3:65:3 | f | tests.go:63:5:63:76 | ... := ...[0] | tests.go:65:3:65:3 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:63:15:63:76 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:107:9:107:9 | f | tests.go:105:5:105:78 | ... := ...[0] | tests.go:107:9:107:9 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:105:15:105:78 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:126:3:126:3 | f | tests.go:122:5:122:78 | ... := ...[0] | tests.go:126:3:126:3 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:122:15:122:78 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:14:3:14:3 | f | tests.go:45:5:45:76 | ... := ...[0] | tests.go:14:3:14:3 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:45:15:45:76 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:56:3:56:3 | f | tests.go:54:5:54:78 | ... := ...[0] | tests.go:56:3:56:3 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:54:15:54:78 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:68:3:68:3 | f | tests.go:66:5:66:76 | ... := ...[0] | tests.go:68:3:68:3 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:66:15:66:76 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:110:9:110:9 | f | tests.go:108:5:108:78 | ... := ...[0] | tests.go:110:9:110:9 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:108:15:108:78 | call to OpenFile | call to OpenFile |
|
||||
| tests.go:129:3:129:3 | f | tests.go:125:5:125:78 | ... := ...[0] | tests.go:129:3:129:3 | f | File handle may be writable as a result of data flow from a $@ and closing it may result in data loss upon failure, which is not handled explicitly. | tests.go:125:15:125:78 | call to OpenFile | call to OpenFile |
|
||||
|
||||
@@ -31,18 +31,21 @@ func deferredCalls() {
|
||||
if f, err := os.OpenFile("foo.txt", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666); err != nil {
|
||||
closeFileDeferred(f) // NOT OK
|
||||
closeFileDeferredIndirect(f) // NOT OK
|
||||
closeFileDeferredIndirectReturn(f)
|
||||
}
|
||||
|
||||
// open file for reading
|
||||
if f, err := os.OpenFile("foo.txt", os.O_RDONLY|os.O_CREATE, 0666); err != nil {
|
||||
closeFileDeferred(f) // OK
|
||||
closeFileDeferredIndirect(f) // OK
|
||||
closeFileDeferredIndirectReturn(f)
|
||||
}
|
||||
|
||||
// open file for reading and writing
|
||||
if f, err := os.OpenFile("foo.txt", os.O_RDWR|os.O_TRUNC|os.O_CREATE, 0666); err != nil {
|
||||
closeFileDeferred(f) // NOT OK
|
||||
closeFileDeferredIndirect(f) // NOT OK
|
||||
closeFileDeferredIndirectReturn(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user