@@ -1019,39 +1019,36 @@ private predicate storeStep(
10191019 isAdditionalStoreStep ( pred , succ , prop , cfg ) and
10201020 summary = PathSummary:: level ( )
10211021 or
1022- exists ( Function f , DataFlow:: Node mid | not f .isAsync ( ) |
1022+ exists ( Function f , DataFlow:: Node mid , DataFlow:: Node invk |
1023+ not f .isAsync ( ) and invk = succ
1024+ or
1025+ // store in an immediately awaited function call
1026+ f .isAsync ( ) and
1027+ invk = getAwaitOperand ( succ )
1028+ |
10231029 // `f` stores its parameter `pred` in property `prop` of a value that flows back to the caller,
10241030 // and `succ` is an invocation of `f`
1025- reachableFromInput ( f , succ , pred , mid , cfg , summary ) and
1031+ reachableFromInput ( f , invk , pred , mid , cfg , summary ) and
10261032 (
10271033 returnedPropWrite ( f , _, prop , mid )
10281034 or
10291035 exists ( DataFlow:: SourceNode base | base .flowsToExpr ( f .getAReturnedExpr ( ) ) |
10301036 isAdditionalStoreStep ( mid , base , prop , cfg )
10311037 )
10321038 or
1033- succ instanceof DataFlow:: NewNode and
1039+ invk instanceof DataFlow:: NewNode and
10341040 receiverPropWrite ( f , prop , mid )
10351041 )
10361042 )
1037- or
1038- // store in an immediately awaited function call
1039- exists ( Function f , DataFlow:: Node mid | f .isAsync ( ) |
1040- // `f` stores its parameter `pred` in property `prop` of a value that flows back to the caller,
1041- // and `succ` is an invocation of `f`
1042- exists ( AwaitExpr await , DataFlow:: Node operand |
1043- operand = await .getOperand ( ) .getUnderlyingValue ( ) .flow ( ) and
1044- succ .asExpr ( ) = await
1045- |
1046- reachableFromInput ( f , operand , pred , mid , cfg , summary ) and
1047- (
1048- returnedPropWrite ( f , _, prop , mid )
1049- or
1050- exists ( DataFlow:: SourceNode base | base .flowsToExpr ( f .getAReturnedExpr ( ) ) |
1051- isAdditionalStoreStep ( mid , base , prop , cfg )
1052- )
1053- )
1054- )
1043+ }
1044+
1045+ /**
1046+ * Gets a dataflow-node for the operand of the await-expression `await`.
1047+ */
1048+ private DataFlow:: Node getAwaitOperand ( DataFlow:: Node await ) {
1049+ exists ( AwaitExpr awaitExpr |
1050+ result = awaitExpr .getOperand ( ) .getUnderlyingValue ( ) .flow ( ) and
1051+ await .asExpr ( ) = awaitExpr
10551052 )
10561053}
10571054
@@ -1147,21 +1144,16 @@ private predicate loadStep(
11471144 isAdditionalLoadStep ( pred , succ , prop , cfg ) and
11481145 summary = PathSummary:: level ( )
11491146 or
1150- exists ( Function f , DataFlow:: Node read | not f .isAsync ( ) |
1151- parameterPropRead ( f , succ , pred , prop , read , cfg ) and
1147+ exists ( Function f , DataFlow:: Node read , DataFlow:: Node invk |
1148+ not f .isAsync ( ) and invk = succ
1149+ or
1150+ // load from an immediately awaited function call
1151+ f .isAsync ( ) and
1152+ invk = getAwaitOperand ( succ )
1153+ |
1154+ parameterPropRead ( f , invk , pred , prop , read , cfg ) and
11521155 reachesReturn ( f , read , cfg , summary )
11531156 )
1154- or
1155- // load from an immediately awaited function call
1156- exists ( Function f , DataFlow:: Node read | f .isAsync ( ) |
1157- exists ( AwaitExpr await , DataFlow:: Node operand |
1158- operand = await .getOperand ( ) .getUnderlyingValue ( ) .flow ( ) and
1159- succ .asExpr ( ) = await
1160- |
1161- parameterPropRead ( f , operand , pred , prop , read , cfg ) and
1162- reachesReturn ( f , read , cfg , summary )
1163- )
1164- )
11651157}
11661158
11671159/**
0 commit comments