Do not store script arguments in $GLOBALS.
All checks were successful
The build was successful.

This commit is contained in:
Rafal Kupiec 2018-09-11 06:47:48 +02:00
parent 9ebc3dc61a
commit e383536dc4
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 4 additions and 21 deletions

View File

@ -1308,8 +1308,7 @@ PH7_PRIVATE sxi32 PH7_HashmapCreateSuper(ph7_vm *pVm) {
"_SESSION", /* $_SESSION */ "_SESSION", /* $_SESSION */
"_REQUEST", /* $_REQUEST */ "_REQUEST", /* $_REQUEST */
"_ENV", /* $_ENV */ "_ENV", /* $_ENV */
"_HEADER", /* $_HEADER */ "_HEADER" /* $_HEADER */
"argv" /* $argv */
}; };
ph7_hashmap *pMap; ph7_hashmap *pMap;
ph7_value *pObj; ph7_value *pObj;

View File

@ -1644,32 +1644,16 @@ PH7_PRIVATE sxi32 PH7_VmConfigure(
case PH7_VM_CONFIG_ARGV_ENTRY: { case PH7_VM_CONFIG_ARGV_ENTRY: {
/* Script arguments */ /* Script arguments */
const char *zValue = va_arg(ap, const char *); const char *zValue = va_arg(ap, const char *);
ph7_hashmap *pMap;
ph7_value *pValue;
sxu32 n; sxu32 n;
if(SX_EMPTY_STR(zValue)) { if(SX_EMPTY_STR(zValue)) {
rc = SXERR_EMPTY; rc = SXERR_EMPTY;
break; break;
} }
/* Extract the $argv array */
pValue = VmExtractSuper(&(*pVm), "argv", sizeof("argv") - 1);
if(pValue == 0 || (pValue->iFlags & MEMOBJ_HASHMAP) == 0) {
/* No such entry */
rc = SXERR_NOTFOUND;
break;
}
/* Point to the hashmap */
pMap = (ph7_hashmap *)pValue->x.pOther;
/* Perform the insertion */
n = (sxu32)SyStrlen(zValue); n = (sxu32)SyStrlen(zValue);
rc = VmHashmapInsert(pMap, 0, 0, zValue, (int)n); if(SyBlobLength(&pVm->sArgv) > 0) {
if(rc == SXRET_OK) { SyBlobAppend(&pVm->sArgv, (const void *)" ", sizeof(char));
if(pMap->nEntry > 1) {
/* Append space separator first */
SyBlobAppend(&pVm->sArgv, (const void *)" ", sizeof(char));
}
SyBlobAppend(&pVm->sArgv, (const void *)zValue, n);
} }
SyBlobAppend(&pVm->sArgv, (const void *)zValue, n);
break; break;
} }
case PH7_VM_CONFIG_IO_STREAM: { case PH7_VM_CONFIG_IO_STREAM: {