@@ -178,7 +178,7 @@ library SafeERC20 {
178178
179179 /**
180180 * @dev Imitates a Solidity `token.transfer(to, value)` call, relaxing the requirement on the return value: the
181- * return value is optional (but if data is returned, it must not be false ).
181+ * return value is optional (but if data is returned, it must decode to true ).
182182 *
183183 * @param token The token targeted by the call.
184184 * @param to The recipient of the tokens
@@ -196,7 +196,7 @@ library SafeERC20 {
196196 success := call (gas (), token, 0 , 0x00 , 0x44 , 0x00 , 0x20 )
197197 // if call success and return is true, all is good.
198198 // otherwise (not success or return is not true), we need to perform further checks
199- if iszero (and (success, eq (mload (0x00 ), 1 ))) {
199+ if iszero (and (success, and ( gt ( returndatasize (), 0x1f ), eq (mload (0x00 ), 1 ) ))) {
200200 // if the call was a failure and bubble is enabled, bubble the error
201201 if and (iszero (success), bubble) {
202202 returndatacopy (fmp, 0x00 , returndatasize ())
@@ -213,7 +213,7 @@ library SafeERC20 {
213213
214214 /**
215215 * @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, relaxing the requirement on the return
216- * value: the return value is optional (but if data is returned, it must not be false ).
216+ * value: the return value is optional (but if data is returned, it must decode to true ).
217217 *
218218 * @param token The token targeted by the call.
219219 * @param from The sender of the tokens
@@ -239,7 +239,7 @@ library SafeERC20 {
239239 success := call (gas (), token, 0 , 0x00 , 0x64 , 0x00 , 0x20 )
240240 // if call success and return is true, all is good.
241241 // otherwise (not success or return is not true), we need to perform further checks
242- if iszero (and (success, eq (mload (0x00 ), 1 ))) {
242+ if iszero (and (success, and ( gt ( returndatasize (), 0x1f ), eq (mload (0x00 ), 1 ) ))) {
243243 // if the call was a failure and bubble is enabled, bubble the error
244244 if and (iszero (success), bubble) {
245245 returndatacopy (fmp, 0x00 , returndatasize ())
@@ -257,7 +257,7 @@ library SafeERC20 {
257257
258258 /**
259259 * @dev Imitates a Solidity `token.approve(spender, value)` call, relaxing the requirement on the return value:
260- * the return value is optional (but if data is returned, it must not be false ).
260+ * the return value is optional (but if data is returned, it must decode to true ).
261261 *
262262 * @param token The token targeted by the call.
263263 * @param spender The spender of the tokens
@@ -275,7 +275,7 @@ library SafeERC20 {
275275 success := call (gas (), token, 0 , 0x00 , 0x44 , 0x00 , 0x20 )
276276 // if call success and return is true, all is good.
277277 // otherwise (not success or return is not true), we need to perform further checks
278- if iszero (and (success, eq (mload (0x00 ), 1 ))) {
278+ if iszero (and (success, and ( gt ( returndatasize (), 0x1f ), eq (mload (0x00 ), 1 ) ))) {
279279 // if the call was a failure and bubble is enabled, bubble the error
280280 if and (iszero (success), bubble) {
281281 returndatacopy (fmp, 0x00 , returndatasize ())
0 commit comments