Fossil

Check-in [f2d87242]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed a segfault in proc_command() caused by invalid inspection of an empty array.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | th1-query-api
Files: files | file ages | folders
SHA1: f2d87242503d7a7dc90abf1e079af38f5aeb6b8e
User & Date: stephan 2012-07-14 19:48:12.541
References
2015-11-21
18:37
Revise TH1 proc_command fix from the previous check-in so it more closely matches the original fix from [f2d87242503d7a7d]. ... (check-in: c66083ed user: mistachkin tags: trunk)
Context
2012-07-14
20:11
Added th1_ob.wiki embedded doc. ... (check-in: 905f67d0 user: stephan tags: th1-query-api)
19:48
Fixed a segfault in proc_command() caused by invalid inspection of an empty array. ... (check-in: f2d87242 user: stephan tags: th1-query-api)
19:19
Documented the "ob" API, added "ob level". ... (check-in: 66104f8b user: stephan tags: th1-query-api)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/th_lang.c.
465
466
467
468
469
470
471

472
473
474

475
476
477
478
479
480
481
      argl[2];     /* Space for copies of parameter names and default values */
  p = (ProcDefn *)Th_Malloc(interp, nByte);

  /* If the last parameter in the parameter list is "args", then set the
  ** ProcDefn.hasArgs flag. The "args" parameter does not require an
  ** entry in the ProcDefn.azParam[] or ProcDefn.azDefault[] arrays.
  */

  if( anParam[nParam-1]==4 && 0==memcmp(azParam[nParam-1], "args", 4) ){
    p->hasArgs = 1;
    nParam--;

  }

  p->nParam    = nParam;
  p->azParam   = (char **)&p[1];
  p->anParam   = (int *)&p->azParam[nParam];
  p->azDefault = (char **)&p->anParam[nParam];
  p->anDefault = (int *)&p->azDefault[nParam];







>
|
|
|
>







465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
      argl[2];     /* Space for copies of parameter names and default values */
  p = (ProcDefn *)Th_Malloc(interp, nByte);

  /* If the last parameter in the parameter list is "args", then set the
  ** ProcDefn.hasArgs flag. The "args" parameter does not require an
  ** entry in the ProcDefn.azParam[] or ProcDefn.azDefault[] arrays.
  */
  if(nParam>0){
    if( anParam[nParam-1]==4 && 0==memcmp(azParam[nParam-1], "args", 4) ){
      p->hasArgs = 1;
      nParam--;
    }
  }

  p->nParam    = nParam;
  p->azParam   = (char **)&p[1];
  p->anParam   = (int *)&p->azParam[nParam];
  p->azDefault = (char **)&p->anParam[nParam];
  p->anDefault = (int *)&p->azDefault[nParam];