diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2026-04-01 15:01:58 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2026-04-01 15:01:58 -0300 |
| commit | efddc2309c5ff8a1842bea8a9c0d7d4a5d6e1e60 (patch) | |
| tree | 10c85aab8380de274878ecde03f1e03438420918 /testes/pm.lua | |
| parent | f1bb2773bba8b16f0f01c00e59a7be541ef88cb7 (diff) | |
| download | lua-efddc2309c5ff8a1842bea8a9c0d7d4a5d6e1e60.tar.gz lua-efddc2309c5ff8a1842bea8a9c0d7d4a5d6e1e60.tar.bz2 lua-efddc2309c5ff8a1842bea8a9c0d7d4a5d6e1e60.zip | |
Bug: wrong initialization in result from 'gmatch'
Function returned by 'string.gmatch' can be left in an inconsistent
state after an error.
Diffstat (limited to '')
| -rw-r--r-- | testes/pm.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/testes/pm.lua b/testes/pm.lua index 720d2a35..feab33db 100644 --- a/testes/pm.lua +++ b/testes/pm.lua | |||
| @@ -347,6 +347,16 @@ do -- init parameter in gmatch | |||
| 347 | end | 347 | end |
| 348 | 348 | ||
| 349 | 349 | ||
| 350 | do -- bug since 5.3 | ||
| 351 | local N = 20000 | ||
| 352 | local iter = string.gmatch(string.rep("a", N), string.rep("a?", N)) | ||
| 353 | pcall(iter) -- error for pattern too complex | ||
| 354 | -- calling function again found recursion count ('matchdepth') equal | ||
| 355 | -- to -1, so it did not detect next C-stack overflow | ||
| 356 | pcall(iter) | ||
| 357 | end | ||
| 358 | |||
| 359 | |||
| 350 | -- tests for `%f' (`frontiers') | 360 | -- tests for `%f' (`frontiers') |
| 351 | 361 | ||
| 352 | assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x") | 362 | assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x") |
