Fossil SCM
If the proc argument list is an empty list, don't segfault by accessing memory outside the bounds of the array. For example, as used in the footer [/artifact/7f36cbf30a82ef3cec30c1917a96415fa7d76eeb?txt=1&ln=3]
Commit
7c3cb470e65bf79274f67d44b3fa2a14d54d18bd
Parent
63256980eef3cff…
1 file changed
+2
-1
+2
-1
| --- src/th_lang.c | ||
| +++ src/th_lang.c | ||
| @@ -495,11 +495,12 @@ | ||
| 495 | 495 | |
| 496 | 496 | /* If the last parameter in the parameter list is "args", then set the |
| 497 | 497 | ** ProcDefn.hasArgs flag. The "args" parameter does not require an |
| 498 | 498 | ** entry in the ProcDefn.azParam[] or ProcDefn.azDefault[] arrays. |
| 499 | 499 | */ |
| 500 | - if( anParam[nParam-1]==4 && 0==memcmp(azParam[nParam-1], "args", 4) ){ | |
| 500 | + if( nParam | |
| 501 | + && anParam[nParam-1]==4 && 0==memcmp(azParam[nParam-1], "args", 4) ){ | |
| 501 | 502 | p->hasArgs = 1; |
| 502 | 503 | nParam--; |
| 503 | 504 | } |
| 504 | 505 | |
| 505 | 506 | p->nParam = nParam; |
| 506 | 507 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -495,11 +495,12 @@ | |
| 495 | |
| 496 | /* If the last parameter in the parameter list is "args", then set the |
| 497 | ** ProcDefn.hasArgs flag. The "args" parameter does not require an |
| 498 | ** entry in the ProcDefn.azParam[] or ProcDefn.azDefault[] arrays. |
| 499 | */ |
| 500 | if( anParam[nParam-1]==4 && 0==memcmp(azParam[nParam-1], "args", 4) ){ |
| 501 | p->hasArgs = 1; |
| 502 | nParam--; |
| 503 | } |
| 504 | |
| 505 | p->nParam = nParam; |
| 506 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -495,11 +495,12 @@ | |
| 495 | |
| 496 | /* If the last parameter in the parameter list is "args", then set the |
| 497 | ** ProcDefn.hasArgs flag. The "args" parameter does not require an |
| 498 | ** entry in the ProcDefn.azParam[] or ProcDefn.azDefault[] arrays. |
| 499 | */ |
| 500 | if( nParam |
| 501 | && anParam[nParam-1]==4 && 0==memcmp(azParam[nParam-1], "args", 4) ){ |
| 502 | p->hasArgs = 1; |
| 503 | nParam--; |
| 504 | } |
| 505 | |
| 506 | p->nParam = nParam; |
| 507 |