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]

andybradford 2015-11-21 17:25 trunk
Commit 7c3cb470e65bf79274f67d44b3fa2a14d54d18bd
1 file changed +2 -1
+2 -1
--- src/th_lang.c
+++ src/th_lang.c
@@ -495,11 +495,12 @@
495495
496496
/* If the last parameter in the parameter list is "args", then set the
497497
** ProcDefn.hasArgs flag. The "args" parameter does not require an
498498
** entry in the ProcDefn.azParam[] or ProcDefn.azDefault[] arrays.
499499
*/
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) ){
501502
p->hasArgs = 1;
502503
nParam--;
503504
}
504505
505506
p->nParam = nParam;
506507
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button