project
stringclasses 633
values | commit_id
stringlengths 7
81
| target
int64 0
1
| func
stringlengths 5
484k
| cwe
stringclasses 131
values | big_vul_idx
float64 0
189k
⌀ | idx
int64 0
522k
| hash
stringlengths 34
39
| size
float64 1
24k
⌀ | message
stringlengths 0
11.5k
⌀ | dataset
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code__fcall(jsi_Pstate *p, jsi_Pline *line, int argc, const char *name, const char *namePre, Jsi_OpCodes *argCodes) {
jsi_FuncCallCheck(p,line,argc,1, name, namePre, argCodes);JSI_NEW_CODESLN(0,OP_FCALL, argc);
}
|
CWE-120
| null | 520,586 |
126574710819524090426622103833750977178
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_InitLocalVar(Jsi_Interp *interp, Jsi_Value *arguments, Jsi_Func *who)
{
SIGASSERTV(who, FUNC);
if (who->localnames) {
int i;
for (i = 0; i < who->localnames->count; ++i) {
const char *argkey = jsi_ScopeStrsGet(who->localnames, i);
if (argkey) {
DECL_VALINIT(key);// = VALINIT;
Jsi_Value *v __attribute__((unused));
Jsi_Value *kPtr = &key; // Note: a string key so no reset needed.
Jsi_ValueMakeStringKey(interp, &kPtr, argkey);
v = jsi_ValueObjKeyAssign(interp, arguments, kPtr, NULL, JSI_OM_DONTENUM);
jsi_ValueDebugLabel(v, "locals", who->name);
}
}
}
}
|
CWE-120
| null | 520,587 |
165769931291354900997445753265068996196
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC NumberIsIntegerCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr) {
return jsi_NumberIsFiniteCmd(interp, args, _this, ret, funcPtr, 2);
}
|
CWE-120
| null | 520,588 |
199572156102959869469269508837934698537
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_PstateAddVar(jsi_Pstate *ps, jsi_Pline *line, const char *str)
{
Jsi_Interp *interp = ps->interp;
int i;
if (interp->scopes[interp->cur_scope] == NULL)
interp->scopes[interp->cur_scope] = (Jsi_ScopeStrs *)jsi_ScopeStrsNew();
for (i = 0; i < interp->scopes[interp->cur_scope]->count; ++i) {
if (Jsi_Strcmp(str, interp->scopes[interp->cur_scope]->args[i].name) == 0) {
Jsi_Interp *interp = ps->interp;
if (interp && interp->strict) {
interp->parseLine = line;
Jsi_LogWarn("duplicate var: %s", str);
interp->parseLine = NULL;
}
return;
}
}
jsi_ScopeStrsPush(ps->interp, interp->scopes[interp->cur_scope], str, JSI_VT_UNDEF);
}
|
CWE-120
| null | 520,589 |
231819568500734632627946403314970402700
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_FunctionInvokeString(Jsi_Interp *interp, Jsi_Value *func, Jsi_Value *arg, Jsi_DString *dStr)
{
if (interp->deleting)
return JSI_ERROR;
Jsi_Value *vpargs, *frPtr = Jsi_ValueNew1(interp);
Jsi_RC rc;
if (!arg) {
if (!interp->nullFuncArg) {
interp->nullFuncArg = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, NULL, 0, 0));
Jsi_IncrRefCount(interp, interp->nullFuncArg);
}
vpargs = interp->nullFuncArg;
} else {
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, &arg, 1, 1));
}
Jsi_IncrRefCount(interp, vpargs);
rc = Jsi_FunctionInvoke(interp, func, vpargs, &frPtr, NULL);
Jsi_DecrRefCount(interp, vpargs);
if (rc != JSI_OK)
Jsi_LogError("function call failed");
else
Jsi_ValueGetDString(interp, frPtr, dStr, 0);
Jsi_DecrRefCount(interp, frPtr);
return rc;
}
|
CWE-120
| null | 520,590 |
101133866582098432296330504819714659072
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value *jsi_GlobalContext(Jsi_Interp *interp)
{
return interp->csc;
}
|
CWE-120
| null | 520,591 |
56785026681726439190407639715540080236
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_wsPathAlias(Jsi_Interp *interp, jsi_wsCmdObj *cmdPtr, const char **inPtr, Jsi_DString *dStr) {
const char *ce, *cp = NULL;
char *lcp;
Jsi_Value *val;
if (cmdPtr->pathAliases) {
cp = *inPtr;
if (*cp == '/') cp++;
if ((ce = Jsi_Strchr(cp, '/'))) {
int len = ce-cp;
Jsi_DSSetLength(dStr, 0);
Jsi_DSAppendLen(dStr, cp, len);
cp = Jsi_DSValue(dStr);
if ((val = Jsi_ValueObjLookup(interp, cmdPtr->pathAliases, cp, 0)) &&
(cp = Jsi_ValueString(interp, val, NULL))) {
*inPtr += (len+2);
cmdPtr->curRoot = cp;
return;
}
}
}
if (!Jsi_Strncmp(*inPtr, "/jsi/", 5)) {
// Get/cache path for system load file, eg /zvfs/lib/Jsish.jsi.
if (!(cp = cmdPtr->jsishPathCache)) {
Jsi_PkgRequire(interp, "Jsish", 0);
if (Jsi_PkgVersion(interp, "Jsish", &cp)>=0)
cmdPtr->jsishPathCache = cp;
}
if (cp) {
Jsi_DSSetLength(dStr, 0);
Jsi_DSAppend(dStr, cp, NULL);
cp = Jsi_DSValue(dStr);
if ((lcp = Jsi_Strrchr(cp, '/'))) {
*lcp = 0;
*inPtr += 5;
cmdPtr->curRoot = cp;
}
}
}
}
|
CWE-120
| null | 520,592 |
12017809785961306044426593532565453003
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC WebSocketFileCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
jsi_wsCmdObj *cmdPtr = (jsi_wsCmdObj*)Jsi_UserObjGetData(interp, _this, funcPtr);
if (!cmdPtr)
return Jsi_LogError("Apply to non-websock object");
Jsi_Value *val = Jsi_ValueArrayIndex(interp, args, 0);
if (val)
return jsi_wsFileAdd(interp, cmdPtr, val);
if (cmdPtr->fileHash)
return Jsi_HashKeysDump(interp, cmdPtr->fileHash, ret, 0);
return JSI_OK;
}
|
CWE-120
| null | 520,593 |
257246475571099739335317985427759027559
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_InitWebSocket(Jsi_Interp *interp, int release)
{
if (release)
return Jsi_DoneWebSocket(interp);
#ifdef LWS_OPENSSL_SUPPORT
Jsi_InterpAccess(interp, NULL, JSI_INTACCESS_SETSSL );
#endif
Jsi_Hash *wsys;
const char *libver = lws_get_library_version();
int lvlen = sizeof(LWS_LIBRARY_VERSION)-1;
if (Jsi_Strncmp(libver, LWS_LIBRARY_VERSION, lvlen) || !isspace(libver[lvlen]))
return Jsi_LogError("Library version mismatch: HDR:%s != LIB:%s", LWS_LIBRARY_VERSION, libver);
#if JSI_USE_STUBS
if (Jsi_StubsInit(interp, 0) != JSI_OK)
return JSI_ERROR;
#endif
Jsi_Value *info = Jsi_ValueNew1(interp);
Jsi_JSONParseFmt(interp, &info, "{libVer:\"%s\", hdrVer:\"%s\", pkgVer:%d}",
libver, LWS_LIBRARY_VERSION, jsi_WsPkgVersion);
Jsi_PkgOpts wsPkgOpts = { wsObjCmd_Specs, &wsObjCmd, websockCmds, info };
Jsi_RC rc = Jsi_PkgProvideEx(interp, "WebSocket", jsi_WsPkgVersion, Jsi_InitWebSocket, &wsPkgOpts);
Jsi_DecrRefCount(interp, info);
if (rc != JSI_OK)
return JSI_ERROR;
if (!(wsys = Jsi_UserObjRegister(interp, &websockobject))) {
Jsi_LogBug("Can not init webSocket");
return JSI_ERROR;
}
if (!Jsi_CommandCreateSpecs(interp, websockobject.name, websockCmds, wsys, JSI_CMDSPEC_ISOBJ))
return JSI_ERROR;
return JSI_OK;
}
|
CWE-120
| null | 520,594 |
278227408171758015904470988860564197165
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueNewNull(Jsi_Interp *interp) {
Jsi_Value *v = Jsi_ValueNew(interp);
v->vt = JSI_VT_NULL;
return v;
}
|
CWE-120
| null | 520,595 |
18371637065584568074167728629697689680
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC _object_get_callback(Jsi_Tree *tree, Jsi_TreeEntry *hPtr, void *data)
{
Jsi_Value *v;
objwalker *ow = (objwalker *)data;
Jsi_DString *dStr = ow->dStr;
int len;
char *str;
if ((hPtr->f.bits.dontenum))
return JSI_OK;
v =(Jsi_Value*) Jsi_TreeValueGet(hPtr);
if ((ow->quote&JSI_OUTPUT_JSON) && v && v->vt == JSI_VT_UNDEF)
return JSI_OK;
str = (char*)Jsi_TreeKeyGet(hPtr);
char *cp = Jsi_DSValue(dStr);
len = Jsi_DSLength(dStr);
if (len>=2 && (cp[len-2] != '{' || cp[len-1] == '}'))
Jsi_DSAppend(dStr, ", ", NULL);
if (((ow->quote&JSI_OUTPUT_JSON) == 0 || (ow->quote&JSI_JSON_STRICT) == 0) && Jsi_StrIsAlnum(str)
&& !Jsi_HashEntryFind(tree->opts.interp->lexkeyTbl, str))
Jsi_DSAppend(dStr, str, NULL);
else
/* JSON/spaces, etc requires quoting the name. */
Jsi_DSAppend(dStr, "\"", str, "\"", NULL);
Jsi_DSAppend(dStr, ":", NULL);
ow->depth++;
Jsi_RC rc = jsiValueGetString(tree->opts.interp, v, dStr, ow);
ow->depth--;
return rc;
}
|
CWE-120
| null | 520,596 |
197073637692639618430972511581282163830
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void delete_case4(Jsi_TreeEntry* n) {
Jsi_TreeEntry* s = sibling(n);
if (node_color(n->parent) == _JSI_TREE_RED &&
node_color(s) == _JSI_TREE_BLACK &&
node_color(s->left) == _JSI_TREE_BLACK &&
node_color(s->right) == _JSI_TREE_BLACK)
{
set_color(s, _JSI_TREE_RED);
set_color(n->parent, _JSI_TREE_BLACK);
}
else
delete_case5(n);
}
|
CWE-120
| null | 520,597 |
100328208923253046584814206785985808690
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value * jsi_ValueNew1(Jsi_Interp *interp, const char *fname, int line, const char *func) {
Jsi_Value *v = ValueNew1(interp);
jsi_ValueDebugUpdate(interp, v, valueDebugTbl, fname, line, func);
return v;
}
|
CWE-120
| null | 520,598 |
331951339878882670879986989252091572224
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static char *get_inputline(Jsi_Interp *interp, int istty, const char *prompt)
{
char *res;
#ifdef JSI_HAS_READLINE
if (istty && interp->subOpts.noReadline==0) {
res = jsi_sh_readline(prompt);
if (res && *res) jsi_sh_add_history(res);
return res;
}
#endif
int done = 0;
char bbuf[JSI_BUFSIZ];
Jsi_DString dStr = {};
if (istty)
fputs(prompt, stdout);
fflush(stdout);
while (!done) { /* Read a line. */
bbuf[0] = 0;
if (fgets(bbuf, sizeof(bbuf), stdin) == NULL)
return NULL;
Jsi_DSAppend(&dStr, bbuf, NULL);
if (Jsi_Strlen(bbuf) < (sizeof(bbuf)-1) || bbuf[sizeof(bbuf)-1] == '\n')
break;
}
res = Jsi_Strdup(Jsi_DSValue(&dStr));
Jsi_DSFree(&dStr);
return res;
}
|
CWE-120
| null | 520,599 |
293110792398420102438799172592553708439
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_neg() { JSI_NEW_CODES(0,OP_NEG, 0); }
|
CWE-120
| null | 520,600 |
325689140416352117553807925597043664110
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_HashEntryDelete(Jsi_HashEntry *entryPtr)
{
Jsi_HashEntry *prevPtr;
Jsi_HashEntry **bucketPtr;
size_t hindex;
Jsi_Hash *tablePtr = entryPtr->tablePtr;
Jsi_Interp *interp = tablePtr->opts.interp;
JSI_NOTUSED(interp);
int cnt = 0;
#ifdef JSI_HAS_SIG_HASHENTRY
SIGASSERT(entryPtr, HASHENTRY);
#endif
if (tablePtr->opts.lockHashProc && (*tablePtr->opts.lockHashProc)(tablePtr, 1) != JSI_OK)
return 0;
if (tablePtr->keyType == JSI_KEYS_ONEWORD) {
hindex = RANDOM_INDEX(tablePtr, (const void *)entryPtr->hval);
} else {
hindex = (entryPtr->hval & tablePtr->mask);
}
bucketPtr = tablePtr->buckets + hindex;
if (*bucketPtr == entryPtr) {
*bucketPtr = entryPtr->nextPtr;
cnt++;
} else {
for (prevPtr = *bucketPtr; /*empty*/; prevPtr = prevPtr->nextPtr) {
if (prevPtr == NULL) {
Jsi_LogBug("malformed bucket chain in Jsi_HashEntryDelete");
}
if (prevPtr->nextPtr == entryPtr) {
prevPtr->nextPtr = entryPtr->nextPtr;
cnt++;
break;
}
}
}
if (tablePtr->opts.freeHashProc && entryPtr->clientData)
(tablePtr->opts.freeHashProc)(tablePtr->opts.interp, entryPtr, entryPtr->clientData);
if (tablePtr->opts.lockHashProc)
(*tablePtr->opts.lockHashProc)(tablePtr, 0);
tablePtr->numEntries--;
Jsi_Free(entryPtr);
return cnt;
}
|
CWE-120
| null | 520,601 |
169853373550285507773701386615009369049
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC dbEvalStep(DbEvalContext *p) {
while( p->zSql[0] || p->pPreStmt ) {
Jsi_RC rc;
if( p->pPreStmt==0 ) {
rc = dbPrepareAndBind(p->jdb, p->zSql, &p->zSql, &p->pPreStmt);
if( rc!=JSI_OK ) return rc;
}
rc = dbEvalStepSub(p, 1, NULL);
if (rc != JSI_BREAK)
return rc;
}
/* Finished */
return JSI_BREAK;
}
|
CWE-120
| null | 520,602 |
20112979209570692855666825260541639718
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void dbTraceHandler(void *cd, const char *zSql)
{
int rc;
Jsi_Db *jdb = (Jsi_Db*)cd;
Jsi_Value *vpargs, *items[2] = {}, *ret;
Jsi_Interp *interp = jdb->interp;
items[0] = Jsi_ValueNewObj(interp, jdb->fobj);
items[1] = Jsi_ValueMakeStringDup(interp, NULL, zSql);
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, items, 2, 0));
Jsi_IncrRefCount(interp, vpargs);
ret = Jsi_ValueNew1(interp);
rc = Jsi_FunctionInvoke(interp, jdb->onTrace, vpargs, &ret, NULL);
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
if (rc != JSI_OK)
jdb->errCnt++;
}
|
CWE-120
| null | 520,603 |
235497819957824411827190790079740370707
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSTellProc(Jsi_Channel chan) { return ftell(_JSI_GETFP(chan,1));}
|
CWE-120
| null | 520,604 |
109743154426161027330422438272123119123
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_GetBoolFromValue(Jsi_Interp* interp, Jsi_Value *value, bool *n)
{
if (!value)
return JSI_ERROR;
if (value->vt == JSI_VT_BOOL) {
*n = value->d.val;
return JSI_OK;
}
if (value->vt == JSI_VT_OBJECT && value->d.obj->ot == JSI_OT_BOOL) {
*n = value->d.obj->d.val;
return JSI_OK;
}
Jsi_LogError("invalid bool");
return JSI_ERROR;
}
|
CWE-120
| null | 520,605 |
297574498182959763859889009451258996389
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_restore_scope(Jsi_Interp* interp, jsi_Pstate *ps, jsi_TryList* trylist,
jsi_ScopeChain **scope, Jsi_Value **currentScope, int *context_id) {
/* JSI_RESTORE_SCOPE(scope_save, curscope_save)*/
if (*scope != (trylist->scope_save)) {
jsi_ScopeChainFree(interp, *scope);
*scope = (trylist->scope_save);
interp->framePtr->ingsc = *scope;
}
if (*currentScope != (trylist->curscope_save)) {
Jsi_DecrRefCount(interp, *currentScope);
*currentScope = (trylist->curscope_save);
interp->framePtr->incsc = *currentScope;
}
*context_id = ps->_context_id++;
}
|
CWE-120
| null | 520,606 |
334607085652441426865835471292975942322
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSRewindProc(Jsi_Channel chan) { rewind(_JSI_GETFP(chan,1)); return 0;}
|
CWE-120
| null | 520,607 |
209039208534937057606681347488942980144
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueMakeNull(Jsi_Interp *interp, Jsi_Value **vPtr) {
Jsi_Value *v = (vPtr?*vPtr:NULL);
if (!v)
v = Jsi_ValueNew(interp);
else
Jsi_ValueReset(interp, vPtr);
v->vt = JSI_VT_NULL;
return v;
}
|
CWE-120
| null | 520,608 |
253941741556755212712685498162526476136
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_sub() { JSI_NEW_CODES(0,OP_SUB, 0); }
|
CWE-120
| null | 520,609 |
128990903003500065792856538044333221815
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Chmod(Jsi_Interp *interp, Jsi_Value* path, int mode) {
void *data;
Jsi_Filesystem *fsPtr = Jsi_FilesystemForPath(interp, path, &data);
if (fsPtr == NULL || !fsPtr->chmodProc) return -1;
return fsPtr->chmodProc(interp, path, mode);
}
|
CWE-120
| null | 520,610 |
237388994144348849250681917819937897870
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_OptionsProcessJSON(Jsi_Interp *interp, Jsi_OptionSpec *opts, void *data, const char *json, Jsi_Wide flags)
{
uint i = 0, r, len;
Jsi_RC rc = JSI_OK;
int result = 0;
int strict = (flags & JSI_JSON_STRICT);
Jsi_JsonTok *tok;
const char *err;
Jsi_Value *v = NULL;
Jsi_DString nStr;
const char *t, *name = NULL;
if (json == NULL)
return 0;
while (isspace(*json))
json++;
if (json[0] == 0)
return 0;
JSI_JSON_DECLARE(pp, tokens, 0);
Jsi_JsonParser *p = &pp;
pp.strict = strict;
pp.flags = flags;
r = Jsi_JsonParse(p, json);
if (r != JSI_JSON_ERR_NONE) {
int ofs = pp.pos, len = Jsi_Strlen(json);
if (ofs<0 || ofs>len)
ofs = 0;
err = p->errStr;
if (!err)
err = Jsi_JsonGetErrname(r);
Jsi_LogError("JSON parse error (%s) at offset %d \"%.30s\"", err, ofs, json+ofs);
result = -1;
goto done;
}
tok = p->tokens;
Jsi_DSInit(&nStr);
if (tok->size%2 || tok->type != JSI_JTYPE_OBJECT) {
result = -1;
goto done;
}
v = Jsi_ValueNew1(interp);
for (i=1; i<p->toknext && i<tok->size; i++) {
if (p->tokens[i].type != JSI_JTYPE_STRING) {
result = Jsi_LogError("expected string at %d", i-1);
goto bail;
}
name = Jsi_JsonGetTokstr(p, json, i, &len);
Jsi_DSSetLength(&nStr, 0);
Jsi_DSAppendLen(&nStr, name, len);
name = Jsi_DSValue(&nStr);
i++;
switch (p->tokens[i].type) {
case JSI_JTYPE_PRIMITIVE:
t = Jsi_JsonGetTokstr(p, json, i, &len);
if ((len == 4 && Jsi_Strncmp(t, "true", len)==0) || (len == 5 && Jsi_Strncmp(t, "false", len)==0)) {
Jsi_ValueMakeBool(interp, &v, (bool)(len==4?1:0));
} else if (len == 4 && Jsi_Strncmp(t, "null", len)==0) {
Jsi_ValueMakeNull(interp, &v);
} else {
char *ep;
Jsi_Number d = strtod(t,&ep);
if (ep>(t+len)) {
result = Jsi_LogError("bad number %*s", len, t);
goto bail;
}
Jsi_ValueMakeNumber(interp, &v, d);
}
break;
case JSI_JTYPE_STRING:
t = Jsi_JsonGetTokstr(p, json, i, &len);
Jsi_DString dStr;
Jsi_DSInit(&dStr);
jsonNewDString(interp, &dStr, t, len);
Jsi_ValueMakeStringKey(interp, &v, Jsi_DSValue(&dStr));
Jsi_DSFree(&dStr);
break;
case JSI_JTYPE_ARRAY:
case JSI_JTYPE_OBJECT:
default:
result = -1;
goto bail;
break;
}
result++;
rc = Jsi_OptionsSet(interp, opts, data, name, v, 0);
if (rc == JSI_OK)
continue;
bail:
Jsi_LogError("bad at field: %s", name);
result = -1;
break;
}
done:
Jsi_DSFree(&nStr);
if (v)
Jsi_DecrRefCount(interp, v);
Jsi_JsonFree(&pp);
return result;
}
|
CWE-120
| null | 520,611 |
67105326685148387919382998348045792147
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_ValueToNumber(Jsi_Interp *interp, Jsi_Value *v)
{
if (v->vt == JSI_VT_NUMBER) return JSI_OK;
Jsi_Number a = Jsi_ValueToNumberInt(interp, v, 0);
Jsi_ValueReset(interp, &v);
Jsi_ValueMakeNumber(interp, &v, a);
return JSI_OK;
}
|
CWE-120
| null | 520,612 |
208826058869535596015251837691297439102
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_ValueToVerify(Jsi_Interp *interp, Jsi_OptionSpec* spec, Jsi_Value *inValue, const char *inStr, void *record, Jsi_Wide flags)
{
if (inStr)
return JSI_ERROR;
Jsi_Value **s = (Jsi_Value**)((char*)record) + spec->offset;
Jsi_ValueHandlerProc *vfunc = (Jsi_ValueHandlerProc*)spec->data;
if (!vfunc)
return Jsi_LogError("custom value spec did not set data: %s", spec->name);
if (!inValue) {
if (*s)
Jsi_DecrRefCount(interp, *s);
*s = NULL;
return JSI_OK;
}
if (vfunc(interp, inValue, spec, record) != JSI_OK)
return JSI_ERROR;
*s = inValue;
if (*s)
Jsi_IncrRefCount(interp, *s);
return JSI_OK;
}
|
CWE-120
| null | 520,613 |
288212510669791782812982016501632443937
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_FunctionPrivData(Jsi_Func *funcPtr)
{
return funcPtr->privData;
}
|
CWE-120
| null | 520,614 |
216348214793129506059038540823286395380
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Mutex* Jsi_MutexNew(Jsi_Interp *interp, int timeout, int flags) {
Jsi_Mutex *mtx = (Jsi_Mutex *)Jsi_Calloc(1,sizeof(Jsi_Mutex));
mtx->lockTimeout = timeout;
mtx->flags = flags;
MutexInit(mtx);
return mtx;
}
|
CWE-120
| null | 520,615 |
323706190531883034302565196965277830947
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC FilesysModeCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
UdfGet(udf, _this, funcPtr);
if (udf->mode)
Jsi_ValueMakeStringKey(interp, ret, udf->mode);
return JSI_OK;
}
|
CWE-120
| null | 520,616 |
43384800081922480069105307923193185072
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_PathNormalize(Jsi_Interp *interp, Jsi_Value **pathPtr) {
Jsi_Value *path = *pathPtr;
if (!path) {
Jsi_DString dStr = {};
*pathPtr = Jsi_ValueNewStringDup(interp, Jsi_GetCwd(interp, &dStr));
Jsi_IncrRefCount(interp, *pathPtr);
Jsi_DSFree(&dStr);
} else {
const char *rn = Jsi_Realpath(interp, path, NULL);
if (!rn) return JSI_ERROR;
Jsi_DecrRefCount(interp, *pathPtr);
*pathPtr = Jsi_ValueNewString(interp, rn, -1);
Jsi_IncrRefCount(interp, *pathPtr);
}
return JSI_OK;
}
|
CWE-120
| null | 520,617 |
135059367109567210384279525269468839457
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
HashString( const char *string)
{
jsi_Hash result = 0;
jsi_Hash c;
while ((c = *string++) != 0)
result += (result << 3) + c;
return (jsi_Hash)result;
}
|
CWE-120
| null | 520,618 |
58602651509490109369333032238112145526
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MutexLock(Jsi_Interp *interp, Jsi_Mutex* mtx) {
int timeout = mtx->lockTimeout;
if (interp && timeout<0)
timeout = interp->lockTimeout;
if (timeout<=0)
EnterCriticalSection(&mtx->mtx);
else {
int cnt = timeout;
while (cnt-- >= 0) {
if (TryEnterCriticalSection(&mtx->mtx))
return JSI_OK;
usleep(1000);
}
Jsi_LogError("lock timed out");
if (interp)
interp->threadErrCnt++;
mtx->threadErrCnt++;
return JSI_ERROR;
}
return JSI_OK;
}
|
CWE-120
| null | 520,619 |
187872556598574370317319702366798473367
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_jfalse_np(int off) { JSI_NEW_CODES(0,OP_JFALSE_NP, off); }
|
CWE-120
| null | 520,620 |
289569988923063995610726686120852209685
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsiEvalOp(Jsi_Interp* interp, jsi_Pstate *ps, char *program,
jsi_ScopeChain *scope, Jsi_Value *currentScope, Jsi_Value *_this, Jsi_Value **ret)
{
Jsi_RC r = JSI_OK;
jsi_Pstate *newps = jsiNewParser(interp, program, NULL, 1);
if (newps) {
int oef = newps->eval_flag;
newps->eval_flag = 1;
interp->ps = newps;
r = jsi_evalcode(newps, NULL, newps->opcodes, scope, currentScope, _this, ret);
if (r) {
Jsi_ValueDup2(interp, &ps->last_exception, newps->last_exception);
}
newps->eval_flag = oef;
interp->ps = ps;
} else {
//Jsi_ValueMakeStringKey(interp, &ps->last_exception, "Syntax Error");
r = JSI_ERROR;
}
return r;
}
|
CWE-120
| null | 520,621 |
305240863787695961120664864691027406274
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void dbPrepStmtFree( Jsi_Db *jdb, SqlPreparedStmt *prep)
{
if (prep->deleting)
return;
prep->deleting = 1;
if (prep->pStmt)
sqlite3_finalize( prep->pStmt );
if (prep->entry) {
Jsi_HashEntry *hPtr = prep->entry;
prep->entry = NULL;
Jsi_HashEntryDelete(hPtr);
}
if (prep->elPtr)
Jsi_ListEntryDelete(prep->elPtr);
Jsi_Free( (char*)prep );
jdb->stmtCacheCnt--;
}
|
CWE-120
| null | 520,622 |
90828372682600096698969872346722202989
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_notequal() { JSI_NEW_CODES(0,OP_NOTEQUAL, 0); }
|
CWE-120
| null | 520,623 |
125378093424875782980537063607288368579
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC FilesysReadCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
int sum = 0, n;
Jsi_DString dStr;
Jsi_DSInit(&dStr);
UdfGet(udf, _this, funcPtr);
char buf[JSI_BUFSIZ];
int argc = Jsi_ValueGetLength(interp, args);
int nsiz = -1, cnt = 0, rsiz;
if (!udf->filename) {
goto bail;
}
if (argc>0 && Jsi_GetIntFromValue(interp, Jsi_ValueArrayIndex(interp, args, 0), &nsiz) != JSI_OK)
goto bail;
while (cnt++ < MAX_LOOP_COUNT) {
rsiz = sizeof(buf);
if (nsiz>0 && ((sum+rsiz)>nsiz))
rsiz = (nsiz-sum);
if ((n = Jsi_Read(interp, udf->chan, buf, rsiz)) <= 0)
break;
Jsi_DSAppendLen(&dStr, buf, n);
sum += n;
if (nsiz>=0 && sum >=nsiz)
break;
}
if (Jsi_DSLength(&dStr)>0)
Jsi_ValueMakeDStringObject(interp, ret, &dStr);
return JSI_OK;
bail:
Jsi_DSFree(&dStr);
Jsi_ValueMakeUndef(interp, ret);
return JSI_OK;
}
|
CWE-120
| null | 520,624 |
235639192954911516698464628814663656280
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_TreeKeysDump(Jsi_Interp *interp, Jsi_Tree *tablePtr, Jsi_Value **ret, int flags) {
char *key;
int n = 0;
Jsi_TreeEntry *hPtr;
Jsi_TreeSearch search;
Jsi_Obj *nobj;
Jsi_MapFmtKeyProc* fmtKeyProc = tablePtr->opts.fmtKeyProc;
if (!fmtKeyProc && tablePtr->keyType == JSI_KEYS_ONEWORD && flags!=JSI_KEYS_ONEWORD )
fmtKeyProc = jsi_treeFmtKey;
if (!fmtKeyProc && tablePtr->keyType >= JSI_KEYS_STRUCT_MINSIZE)
return Jsi_LogError("Can not dump struct tree");
nobj = Jsi_ObjNew(interp);
Jsi_ValueMakeArrayObject(interp, ret, nobj);
for (hPtr = Jsi_TreeSearchFirst(tablePtr, &search, flags, NULL);
hPtr != NULL; hPtr = Jsi_TreeSearchNext(&search)) {
key = (char*)Jsi_TreeKeyGet(hPtr);
Jsi_Value *val;
if (fmtKeyProc) {
val = (*fmtKeyProc)((Jsi_MapEntry*)hPtr, &tablePtr->opts, flags);
if (!val) {
Jsi_LogError("key format failed");
Jsi_ValueMakeUndef(interp, ret);
return JSI_ERROR;
}
} else if (tablePtr->keyType == JSI_KEYS_ONEWORD)
val = Jsi_ValueNewNumber(interp, (Jsi_Number)(uintptr_t)key);
else
val = Jsi_ValueNewStringKey(interp, key);
Jsi_ObjArraySet(interp, nobj, val, n++);
if (fmtKeyProc && val->refCnt>1) //TODO: Hmmm. for StructKey Jsi_OptionsDump() returns refCnt=1
Jsi_DecrRefCount(interp, val);
}
Jsi_TreeSearchDone(&search);
return JSI_OK;
}
|
CWE-120
| null | 520,625 |
84913718867721353823010944840026088540
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Remove(Jsi_Interp *interp, Jsi_Value* path, int flags) {
void *data;
Jsi_Filesystem *fsPtr = Jsi_FilesystemForPath(interp, path, &data);
if (fsPtr == NULL || !fsPtr->removeProc) return -1;
return fsPtr->removeProc(interp, path, flags);
}
|
CWE-120
| null | 520,626 |
116212392130925012925572616114032169191
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
const char* Jsi_ValueGetDString(Jsi_Interp *interp, Jsi_Value* v, Jsi_DString *dStr, int quote)
{
objwalker ow;
ow.quote = quote;
ow.depth = 0;
ow.dStr = dStr;
jsiValueGetString(interp, v, dStr, &ow);
return Jsi_DSValue(dStr);
}
|
CWE-120
| null | 520,627 |
166927713038116401873809162091481986875
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsiSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv) {
SqlFunc *p = (SqlFunc*)sqlite3_user_data(context);
int i;
int rc;
Jsi_Interp *interp = p->interp;
Jsi_Value *vpargs, *itemsStatic[100], **items = itemsStatic, *ret;
if (argc>100)
items = (Jsi_Value**)Jsi_Calloc(argc, sizeof(Jsi_Value*));
for(i=0; i<argc; i++) {
items[i] = dbGetValueGet(interp, argv[i]);
}
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, items, argc, 0));
Jsi_IncrRefCount(interp, vpargs);
ret = Jsi_ValueNew1(interp);
rc = Jsi_FunctionInvoke(interp, p->tocall, vpargs, &ret, NULL);
Jsi_DecrRefCount(interp, vpargs);
if (items != itemsStatic)
Jsi_Free(items);
bool b;
if( rc != JSI_OK) {
char buf[JSI_BUFSIZ];
snprintf(buf, sizeof(buf), "error in function: %.200s", p->zName);
sqlite3_result_error(context, buf, -1);
} else if (Jsi_ValueIsBoolean(interp, ret)) {
Jsi_GetBoolFromValue(interp, ret, &b);
sqlite3_result_int(context, b);
} else if (Jsi_ValueIsNumber(interp, ret)) {
Jsi_Number d;
// if (Jsi_GetIntFromValueBase(interp, ret, &i, 0, JSI_NO_ERRMSG);
// sqlite3_result_int64(context, v);
Jsi_GetNumberFromValue(interp, ret, &d);
sqlite3_result_double(context, (double)d);
} else {
const char * data;
if (!(data = Jsi_ValueGetStringLen(interp, ret, &i))) {
//TODO: handle objects???
data = Jsi_ValueToString(interp, ret, NULL);
i = Jsi_Strlen(data);
}
sqlite3_result_text(context, (char *)data, i, SQLITE_TRANSIENT );
}
Jsi_DecrRefCount(interp, ret);
}
|
CWE-120
| null | 520,628 |
206692964639196315569408076756223744816
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Mutex* Jsi_MutexNew(Jsi_Interp *interp, int timeout, int flags) { return NULL; }
|
CWE-120
| null | 520,629 |
168080403542135529518559985079949075676
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Value *jsi_treeFmtKey(Jsi_MapEntry* h, struct Jsi_MapOpts *opts, int flags)
{
Jsi_TreeEntry* hPtr = (Jsi_TreeEntry*)h;
void *key = Jsi_TreeKeyGet(hPtr);
if (opts->keyType == JSI_KEYS_ONEWORD)
return Jsi_ValueNewNumber(opts->interp, (Jsi_Number)(intptr_t)key);
char nbuf[JSI_MAX_NUMBER_STRING];
snprintf(nbuf, sizeof(nbuf), "%p", key);
return Jsi_ValueNewStringDup(opts->interp, nbuf);
}
|
CWE-120
| null | 520,630 |
298526017645114594532289000844035268007
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSGetcProc(Jsi_Channel chan) {
return fgetc(_JSI_GETFP(chan,1));
}
|
CWE-120
| null | 520,631 |
303832195426134192342893831624516256292
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC WebSocketHandlerCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
jsi_wsCmdObj *cmdPtr = (jsi_wsCmdObj*)Jsi_UserObjGetData(interp, _this, funcPtr);
Jsi_HashEntry *hPtr;
jsi_wsHander *hdlPtr;
if (!cmdPtr)
return Jsi_LogError("Apply in a non-websock object");
WSSIGASSERT(cmdPtr, OBJ);
int argc = Jsi_ValueGetLength(interp, args);
if (argc == 0) {
Jsi_HashSearch search;
Jsi_Obj* obj = Jsi_ObjNew(interp);
for (hPtr = Jsi_HashSearchFirst(cmdPtr->handlers, &search); hPtr; hPtr = Jsi_HashSearchNext(&search)) {
const char *key = (char*)Jsi_HashKeyGet(hPtr);
Jsi_Value *val = (Jsi_Value*)Jsi_HashValueGet(hPtr);
Jsi_ObjInsert(interp, obj, key, val, 0);
}
Jsi_ValueMakeObject(interp, ret, obj);
return JSI_OK;
}
if (argc == 1) {
hPtr = Jsi_HashEntryFind(cmdPtr->handlers, Jsi_ValueArrayIndexToStr(interp, args, 0, NULL));
if (!hPtr)
return JSI_OK;
hdlPtr = (jsi_wsHander*)Jsi_HashValueGet(hPtr);
Jsi_ValueReplace(interp, ret, hdlPtr->val);
return JSI_OK;
}
const char *key = Jsi_ValueArrayIndexToStr(interp, args, 0, NULL);
Jsi_Value *valPtr = Jsi_ValueArrayIndex(interp, args, 1);
if (Jsi_ValueIsNull(interp, valPtr)) {
hPtr = Jsi_HashEntryFind(cmdPtr->handlers, key);
if (!hPtr)
return JSI_OK;
hdlPtr = (jsi_wsHander*)Jsi_HashValueGet(hPtr);
if (hdlPtr->val)
Jsi_DecrRefCount(interp, hdlPtr->val);
Jsi_HashValueSet(hPtr, NULL);
Jsi_HashEntryDelete(hPtr);
Jsi_Free(hdlPtr);
Jsi_ValueMakeStringDup(interp, ret, key);
return JSI_OK;
}
if (Jsi_ValueIsFunction(interp, valPtr)==0 && Jsi_ValueIsString(interp, valPtr)==0)
return Jsi_LogError("expected string, function or null");
Jsi_Value *argPtr = Jsi_ValueArrayIndex(interp, args, 2);
if (argPtr) {
if (Jsi_ValueIsNull(interp, argPtr))
argPtr = NULL;
else if (!Jsi_ValueIsString(interp, argPtr))
return Jsi_LogError("expected a string");
}
hPtr = Jsi_HashEntryNew(cmdPtr->handlers, key, NULL);
if (!hPtr)
return JSI_ERROR;
hdlPtr = (jsi_wsHander *)Jsi_Calloc(1, sizeof(*hdlPtr));
Jsi_Value *flagPtr = Jsi_ValueArrayIndex(interp, args, 1);
Jsi_Number fl = 0;
if (flagPtr && Jsi_ValueIsNumber(interp, flagPtr))
Jsi_ValueGetNumber(interp, flagPtr, &fl);
hdlPtr->val = valPtr;
hdlPtr->flags = fl;
Jsi_HashValueSet(hPtr, hdlPtr);
Jsi_IncrRefCount(interp, valPtr);
return JSI_OK;
}
|
CWE-120
| null | 520,632 |
85161636732486058721191016941875474413
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value * jsi_ValueNew(Jsi_Interp *interp, const char *fname, int line, const char *func) {
Jsi_Value *v = ValueNew(interp);
jsi_ValueDebugUpdate(interp, v, valueDebugTbl, fname, line, func);
return v;
}
|
CWE-120
| null | 520,633 |
118377016757688656240591333802440961099
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_evalcode_sub(jsi_Pstate *ps, Jsi_OpCodes *opcodes,
jsi_ScopeChain *scope, Jsi_Value *currentScope,
Jsi_Value *_this, Jsi_Value *vret)
{
Jsi_Interp* interp = ps->interp;
jsi_OpCode *ip = &opcodes->codes[0];
Jsi_RC rc = JSI_OK;
int curLine = 0;
int context_id = ps->_context_id++, lop = -1;
jsi_OpCode *end = &opcodes->codes[opcodes->code_len];
jsi_TryList *trylist = NULL;
bool strict = interp->strict;
const char *curFile = NULL;
if (currentScope->vt != JSI_VT_OBJECT) {
Jsi_LogBug("Eval: current scope is not a object");
return JSI_ERROR;
}
if (interp->maxDepth>0 && interp->level > interp->maxDepth)
rc = Jsi_LogError("Exceeded call depth: %d", interp->level);
while(ip < end && rc == JSI_OK) {
int plop = ip->op;
if (ip->logflag) { // Mask out LogDebug, etc if not enabled.
interp->curIp = ip;
switch (ip->logflag) {
case jsi_Oplf_assert:
if (!interp->asserts) {
ip++;
if (ip->logflag != jsi_Oplf_assert && (ip->op == OP_POP || ip->op == OP_RET))
ip++;
continue;
}
break;
case jsi_Oplf_debug:
if (!interp->logOpts.Debug && !(interp->framePtr->logflag &(1<<jsi_Oplf_debug))) {
ip++;
if (ip->logflag != jsi_Oplf_debug && (ip->op == OP_POP || ip->op == OP_RET))
ip++;
continue;
}
break;
case jsi_Oplf_test:
if (!interp->logOpts.Test && !(interp->framePtr->logflag &(1<<jsi_Oplf_test))) {
ip++;
if (ip->logflag != jsi_Oplf_test && (ip->op == OP_POP || ip->op == OP_RET))
ip++;
continue;
}
break;
case jsi_Oplf_trace:
if (!interp->logOpts.Trace && !(interp->framePtr->logflag &(1<<jsi_Oplf_trace))) {
ip++;
if (ip->logflag != jsi_Oplf_trace && (ip->op == OP_POP || ip->op == OP_RET))
ip++;
continue;
}
break;
default:
break;
}
}
if (interp->interrupted) {
if (!interp->framePtr->tryDepth) {
Jsi_LogError("program interrupted: function=%s", interp->framePtr->funcName);
interp->interrupted = 0;
} else {
interp->interrupted++;
}
rc = JSI_ERROR;
break;
}
if (interp->exited) {
rc = JSI_ERROR;
break;
}
interp->opCnt++;
if (interp->maxOpCnt && interp->opCnt > interp->maxOpCnt) {
puts("EXEC CAP EXCEED");
interp->maxOpCnt += 1000;
rc = Jsi_LogError("Exceeded execution cap: %d", interp->opCnt);
interp->exited = 1;
interp->exitCode = 99;
break;
}
if (interp->traceOp) {
jsiDumpInstr(interp, ps, _this, trylist, ip, opcodes);
}
if (interp->parent && interp->busyCallback && (interp->opCnt%(interp->busyInterval<=0?100000:interp->busyInterval))==0) {
// Handle parent interp events.
if (jsi_FuncIsNoop(interp, interp->busyCallback))
Jsi_EventProcess(interp->parent, -1);
else {
Jsi_DString nStr;
Jsi_DSInit(&nStr);
Jsi_DSPrintf(&nStr, "[\"#Interp_%d\", %d]", interp->objId, interp->opCnt);//TODO: use actual time interval rather than opCnt.
if (Jsi_FunctionInvokeJSON(interp->parent, interp->busyCallback, Jsi_DSValue(&nStr), NULL) != JSI_OK)
rc = JSI_ERROR;
Jsi_DSFree(&nStr);
}
}
ip->hit=1;
#ifndef USE_STATIC_STACK
if ((interp->maxStack-interp->framePtr->Sp)<STACK_MIN_PAD)
jsiSetupStack(interp);
#endif
jsiPush(interp,0);
interp->curIp = ip;
// Carry forward line/file info from previous OPs.
if (!ip->Line)
ip->Line = curLine;
else
curLine = ip->Line;
if (!ip->fname)
ip->fname = curFile;
else
curFile = ip->fname;
if (interp->debugOpts.hook) {
interp->framePtr->fileName = curFile;
interp->framePtr->line = curLine;
if ((rc = (*interp->debugOpts.hook)(interp, curFile, curLine, interp->framePtr->level, interp->curFunction, jsi_opcode_string(ip->op), ip, NULL)) != JSI_OK)
break;
}
switch(ip->op) {
case OP_NOP:
case OP_LASTOP:
break;
case OP_PUSHUND:
Jsi_ValueMakeUndef(interp, &_jsi_STACKIDX(interp->framePtr->Sp));
jsiPush(interp,1);
break;
case OP_PUSHNULL:
Jsi_ValueMakeNull(interp, &_jsi_STACKIDX(interp->framePtr->Sp));
jsiPush(interp,1);
break;
case OP_PUSHBOO:
Jsi_ValueMakeBool(interp, &_jsi_STACKIDX(interp->framePtr->Sp), (uintptr_t)ip->data);
jsiPush(interp,1);
break;
case OP_PUSHNUM:
Jsi_ValueMakeNumber(interp, &_jsi_STACKIDX(interp->framePtr->Sp), (*((Jsi_Number *)ip->data)));
jsiPush(interp,1);
break;
case OP_PUSHSTR: {
Jsi_Value **v = &_jsi_STACKIDX(interp->framePtr->Sp);
Jsi_ValueMakeStringKey(interp, v, (char*)ip->data);
interp->lastPushStr = Jsi_ValueString(interp, *v, NULL);
jsiPush(interp,1);
break;
}
case OP_PUSHVSTR: {
Jsi_String *s = (Jsi_String *)ip->data;
Jsi_Value **v = &_jsi_STACKIDX(interp->framePtr->Sp);
if (s->flags&1)
jsi_ValueMakeBlobDup(interp,v, (uchar*)s->str, s->len);
else {
Jsi_ValueMakeStringKey(interp, v, s->str);
interp->lastPushStr = s->str;
}
jsiPush(interp,1);
break;
}
case OP_PUSHVAR: {
rc = jsi_PushVar(ps, ip, scope, currentScope, context_id);
break;
}
case OP_PUSHFUN: {
jsi_PushFunc(ps, ip, scope, currentScope);
break;
}
case OP_NEWFCALL:
if (interp->maxUserObjs && interp->userObjCnt > interp->maxUserObjs) {
rc = Jsi_LogError("Max 'new' count exceeded");
break;
}
case OP_FCALL: {
/* TODO: need reliable way to capture func string name to handle unknown functions.*/
int discard = ((ip+1)<end && ip[1].op == OP_POP);
switch (jsiEvalFunction(ps, ip, discard)) { /* throw an execption */
case JSI_OK: break;
case JSI_BREAK:
if (interp->framePtr->tryDepth<=0)
interp->isHelp = 1;
JSI_DO_THROW("help");
break;
default:
JSI_DO_THROW("fcall");
}
strict = interp->strict;
/* TODO: new Function return a function without scopechain, add here */
break;
}
case OP_SUBSCRIPT: {
rc = jsi_evalSubscript(interp, _jsi_TOQ, _jsi_TOP, ip, end, currentScope);
break;
}
case OP_ASSIGN: {
Jsi_Value *sval = _jsi_TOP, *dval = _jsi_TOQ;
bool globThis = (sval->vt == JSI_VT_OBJECT && sval->d.obj == interp->csc->d.obj);
if ((uintptr_t)ip->data == 1) {
jsiVarDeref(interp,1);
rc = jsi_ValueAssign(interp, dval, sval, lop);
if (strict && sval->vt == JSI_VT_UNDEF)
rc = jsi_ValueAssignCheck(interp, sval, lop);
jsiPop(interp,1);
} else {
jsiVarDeref(interp, 3);
Jsi_Value *v3 = _jsi_STACKIDX(interp->framePtr->Sp-3);
if (v3->vt == JSI_VT_OBJECT) {
if (strict && sval->vt == JSI_VT_UNDEF)
rc = jsi_ValueAssignCheck(interp, sval, lop);
jsi_ValueObjKeyAssign(interp, v3, dval, sval, 0);
jsi_ValueDebugLabel(sval, "assign", NULL);
} else if (strict)
rc = Jsi_LogError("assign to a non-exist object");
jsiClearStack(interp,3);
Jsi_ValueCopy(interp,v3, sval);
dval = v3;
jsiPop(interp, 2);
}
if (interp->framePtr->level<=1 && globThis && rc == JSI_OK && dval && dval->vt == JSI_VT_VARIABLE) {
dval = dval->d.lval;
//printf("GLOBAL THIS: %p\n", dval);
Jsi_HashSet(interp->genValueTbl, dval, dval);
}
break;
}
case OP_PUSHREG: {
Jsi_Obj *obj = Jsi_ObjNewType(interp, JSI_OT_REGEXP);
obj->d.robj = (Jsi_Regex *)ip->data;
Jsi_ValueMakeObject(interp, &_jsi_STACKIDX(interp->framePtr->Sp), obj);
jsiPush(interp,1);
break;
}
case OP_PUSHARG:
//Jsi_ValueCopy(interp,_jsi_STACKIDX(interp->framePtr->Sp), currentScope);
if (!interp->framePtr->arguments) {
interp->framePtr->arguments = Jsi_ValueNewObj(interp,
Jsi_ObjNewArray(interp, currentScope->d.obj->arr, currentScope->d.obj->arrCnt, 0));
Jsi_IncrRefCount(interp, interp->framePtr->arguments);
if (interp->hasCallee) {
Jsi_Value *callee = Jsi_ValueObjLookup(interp, currentScope, "\1callee\1", 0);
if (callee)
Jsi_ValueInsert(interp, interp->framePtr->arguments, "\1callee\1", callee, JSI_OM_DONTENUM);
}
// interp->framePtr->arguments->d.obj->__proto__ = interp->Object_prototype; // ecma
}
Jsi_ValueCopy(interp,_jsi_STACKIDX(interp->framePtr->Sp), interp->framePtr->arguments);
jsiPush(interp,1);
break;
case OP_PUSHTHS: { //TODO: Value copy can cause memory leak!
Jsi_Value *tval = _jsi_STACKIDX(interp->framePtr->Sp);
Jsi_ValueCopy(interp, tval, _this);
/*if (interp->csc == _this)
Jsi_ValueDup2(interp, &tval, _this);
else
Jsi_ValueCopy(interp, tval, _this);*/
jsiPush(interp,1);
break;
}
case OP_PUSHTOP:
Jsi_ValueCopy(interp,_jsi_STACKIDX(interp->framePtr->Sp), _jsi_TOP);
jsiPush(interp,1);
break;
case OP_UNREF:
jsiVarDeref(interp,1);
break;
case OP_PUSHTOP2: {
Jsi_Value *vp1 = _jsi_STACKIDX(interp->framePtr->Sp);
Jsi_Value *vp2 = _jsi_STACKIDX(interp->framePtr->Sp+1);
if (!vp1 || !vp2)
rc = Jsi_LogError("Invalid lookup/push");
else {
Jsi_ValueCopy(interp, vp1, _jsi_TOQ);
Jsi_ValueCopy(interp, vp2, _jsi_TOP);
jsiPush(interp, 2);
}
break;
}
case OP_CHTHIS: {
if (ip->data) {
int t = interp->framePtr->Sp - 2;
Assert(t>=0);
Jsi_Value *v = _jsi_THISIDX(t);
jsiClearThis(interp, t);
Jsi_ValueCopy(interp, v, _jsi_TOQ);
if (v->vt == JSI_VT_VARIABLE) {
Jsi_ValueCopy(interp, v, v->d.lval);
}
Jsi_ValueToObject(interp, v);
}
break;
}
case OP_LOCAL: {
Jsi_Value key = VALINIT, *kPtr = &key; // Note we use a string key so no reset needed.
Jsi_ValueMakeStringKey(interp, &kPtr, (char*)ip->data);
jsi_ValueObjKeyAssign(interp, currentScope, kPtr, NULL, JSI_OM_DONTENUM);
context_id = ps->_context_id++;
break;
}
case OP_POP: {
Jsi_Value *tval = _jsi_TOP;
if ((interp->evalFlags&JSI_EVAL_RETURN) && (ip+1) >= end &&
(Jsi_ValueIsObjType(interp, tval, JSI_OT_ITER)==0 &&
Jsi_ValueIsObjType(interp, tval, JSI_OT_FUNCTION)==0)) {
/* Interactive and last instruction is a pop: save result. */
Jsi_ValueMove(interp, vret, tval); /*TODO***: correct ***/
tval->vt = JSI_VT_UNDEF;
}
jsiPop(interp, (uintptr_t)ip->data);
break;
}
case OP_NEG:
jsiVarDeref(interp,1);
Jsi_ValueToNumber(interp, _jsi_TOP);
rc = _jsi_StrictChk(_jsi_TOP);
_jsi_TOP->d.num = -(_jsi_TOP->d.num);
break;
case OP_POS:
jsiVarDeref(interp,1);
Jsi_ValueToNumber(interp, _jsi_TOP);
rc = _jsi_StrictChk(_jsi_TOP);
break;
case OP_NOT: {
int val = 0;
jsiVarDeref(interp,1);
val = Jsi_ValueIsTrue(interp, _jsi_TOP);
jsiClearStack(interp,1);
Jsi_ValueMakeBool(interp, &_jsi_TOP, !val);
break;
}
case OP_BNOT: {
jsiVarDeref(interp,1);
jsi_ValueToOInt32(interp, _jsi_TOP);
rc = _jsi_StrictChk(_jsi_TOP);
_jsi_TOP->d.num = (Jsi_Number)(~((int)_jsi_TOP->d.num));
break;
}
case OP_ADD: {
jsiVarDeref(interp,2);
Jsi_Value *v, *v1 = _jsi_TOP, *v2 = _jsi_TOQ;
int l1, l2;
if (strict)
if (Jsi_ValueIsUndef(interp, v1) || Jsi_ValueIsUndef(interp, v2)) {
rc = Jsi_LogError("operand value to + is undefined");
break;
}
char *s1 = Jsi_ValueString(interp, v1, &l1);
char *s2 = Jsi_ValueString(interp, v2, &l2);
if (s1 || s2) {
char *str;
if (!(s1 && s2)) {
v = (s1 ? v2 : v1);
jsi_ValueToPrimitive(interp, &v);
Jsi_ValueToString(interp, v, NULL);
str = Jsi_ValueString(interp, v, (s1?&l2:&l1));
if (s1) s2 = str; else s1 = str;
}
Assert(l1>=0 && l1<=JSI_MAX_ALLOC_BUF);
Assert(l2>=0 && l2<=JSI_MAX_ALLOC_BUF);
str = (char*)Jsi_Malloc(l1+l2+1);
memcpy(str, s2, l2);
memcpy(str+l2, s1, l1);
str[l1+l2] = 0;
jsiClearStack(interp,2);
Jsi_ValueMakeBlob(interp, &v2, (uchar*)str, l1+l2);
} else {
Jsi_ValueToNumber(interp, v1);
Jsi_ValueToNumber(interp, v2);
rc = _jsi_StrictChk2(v1, v2);
Jsi_Number n = v1->d.num + v2->d.num;
jsiClearStack(interp,2);
Jsi_ValueMakeNumber(interp, &v2, n);
}
jsiPop(interp,1);
break;
}
case OP_IN: {
Jsi_Value *v, *vl;
const char *cp = NULL;
Jsi_Number nval;
jsiVarDeref(interp,2);
vl = _jsi_TOQ;
v = _jsi_TOP;
if (Jsi_ValueIsString(interp,vl))
cp = Jsi_ValueGetStringLen(interp, vl, NULL);
else if (Jsi_ValueIsNumber(interp,vl))
Jsi_ValueGetNumber(interp, vl, &nval);
else {
if (strict)
Jsi_LogWarn("expected string or number before IN");
Jsi_ValueMakeBool(interp, &_jsi_TOQ, 0);
jsiPop(interp,1);
break;
}
if (v->vt == JSI_VT_VARIABLE) {
v = v->d.lval;
SIGASSERT(v, VALUE);
}
if (v->vt != JSI_VT_OBJECT || v->d.obj->ot != JSI_OT_OBJECT) {
if (strict)
Jsi_LogWarn("expected object after IN");
Jsi_ValueMakeBool(interp, &_jsi_TOQ, 0);
jsiPop(interp,1);
break;
}
int bval = 0;
char nbuf[JSI_MAX_NUMBER_STRING];
Jsi_Value *vv;
Jsi_Obj *obj = v->d.obj;
if (!cp) {
snprintf(nbuf, sizeof(nbuf), "%d", (int)nval);
cp = nbuf;
}
if (obj->arr) {
vv = jsi_ObjArrayLookup(interp, obj, (char*)cp);
} else {
vv = Jsi_TreeObjGetValue(obj, (char*)cp, 1);
}
bval = (vv != 0);
Jsi_ValueMakeBool(interp, &_jsi_TOQ, bval);
jsiPop(interp,1);
break;
}
case OP_SUB:
common_math_opr(-); break;
case OP_MUL:
common_math_opr(*); break;
case OP_DIV:
common_math_opr(/); break;
case OP_MOD: {
jsiVarDeref(interp,2);
if (!Jsi_ValueIsType(interp,_jsi_TOP, JSI_VT_NUMBER))
Jsi_ValueToNumber(interp, _jsi_TOP);
if (!Jsi_ValueIsType(interp,_jsi_TOQ, JSI_VT_NUMBER))
Jsi_ValueToNumber(interp, _jsi_TOQ);
rc = _jsi_StrictChk2(_jsi_TOP,_jsi_TOQ);
if (rc == JSI_OK)
_jsi_TOQ->d.num = fmod(_jsi_TOQ->d.num, _jsi_TOP->d.num);
jsiPop(interp,1);
break;
}
case OP_LESS:
jsiVarDeref(interp,2);
rc = jsi_logic_less(interp,2,1);
jsiPop(interp,1);
break;
case OP_GREATER:
jsiVarDeref(interp,2);
rc = jsi_logic_less(interp,1,2);
jsiPop(interp,1);
break;
case OP_LESSEQU:
jsiVarDeref(interp,2);
rc = jsi_logic_less(interp,1,2);
if (rc == JSI_OK)
_jsi_TOQ->d.val = !_jsi_TOQ->d.val;
jsiPop(interp,1);
break;
case OP_GREATEREQU:
jsiVarDeref(interp,2);
rc = jsi_logic_less(interp,2,1);
if (rc == JSI_OK)
_jsi_TOQ->d.val = !_jsi_TOQ->d.val;
jsiPop(interp,1);
break;
case OP_EQUAL:
case OP_NOTEQUAL: {
jsiVarDeref(interp,2);
int r = Jsi_ValueCmp(interp, _jsi_TOP, _jsi_TOQ, 0);
r = (ip->op == OP_EQUAL ? !r : r);
jsiClearStack(interp,2);
Jsi_ValueMakeBool(interp, &_jsi_TOQ, r);
jsiPop(interp,1);
break;
}
case OP_STRICTEQU:
case OP_STRICTNEQ: {
int r = 0;
jsiVarDeref(interp,2);
rc = _jsi_StrictUChk3(_jsi_TOQ, _jsi_TOP);
r = !Jsi_ValueIsEqual(interp, _jsi_TOP, _jsi_TOQ);
r = (ip->op == OP_STRICTEQU ? !r : r);
jsiClearStack(interp,2);
Jsi_ValueMakeBool(interp, &_jsi_TOQ, r);
jsiPop(interp,1);
break;
}
case OP_BAND:
common_bitwise_opr(&); break;
case OP_BOR:
common_bitwise_opr(|); break;
case OP_BXOR:
common_bitwise_opr(^); break;
case OP_SHF: {
jsiVarDeref(interp,2);
jsi_ValueToOInt32(interp, _jsi_TOQ);
jsi_ValueToOInt32(interp, _jsi_TOP);
int t1 = (int)_jsi_TOQ->d.num;
int t2 = ((unsigned int)_jsi_TOP->d.num) & 0x1f;
if (ip->data) { /* shift right */
if ((uintptr_t)ip->data == 2) { /* unsigned shift */
unsigned int t3 = (unsigned int)t1;
t3 >>= t2;
Jsi_ValueMakeNumber(interp, &_jsi_TOQ, t3);
} else {
t1 >>= t2;
Jsi_ValueMakeNumber(interp, &_jsi_TOQ, t1);
}
} else {
t1 <<= t2;
Jsi_ValueMakeNumber(interp, &_jsi_TOQ, t1);
}
jsiPop(interp,1);
break;
}
case OP_KEY: {
jsiVarDeref(interp,1);
if (ip->isof && !Jsi_ValueIsArray(interp, _jsi_TOP)) {
rc = Jsi_LogError("operand not an array");
break;
}
if (_jsi_TOP->vt != JSI_VT_UNDEF && _jsi_TOP->vt != JSI_VT_NULL)
Jsi_ValueToObject(interp, _jsi_TOP);
Jsi_Value *spret = Jsi_ValueNew1(interp);
jsi_ValueObjGetKeys(interp, _jsi_TOP, spret, ip->isof);
Jsi_ValueReplace(interp, _jsi_STACK+interp->framePtr->Sp, spret);
Jsi_DecrRefCount(interp, spret);
jsiPush(interp,1);
break;
}
case OP_NEXT: {
Jsi_Value *toq = _jsi_TOQ, *top = _jsi_TOP;
if (toq->vt != JSI_VT_OBJECT || toq->d.obj->ot != JSI_OT_ITER) Jsi_LogBug("next: toq not a iter\n");
if (top->vt != JSI_VT_VARIABLE) {
rc = Jsi_LogError ("invalid for/in left hand-side");
break;
}
if (strict && top->f.bits.local==0) {
const char *varname = "";
Jsi_Value *v = top->d.lval;
if (v->f.bits.lookupfailed)
varname = v->d.lookupFail;
rc = Jsi_LogError("function created global: \"%s\"", varname);
break;
}
Jsi_IterObj *io = toq->d.obj->d.iobj;
if (io->iterCmd) {
io->iterCmd(io, top, _jsi_STACKIDX(interp->framePtr->Sp-3), io->iter++);
} else {
while (io->iter < io->count) {
if (!io->isArrayList) {
if (Jsi_ValueKeyPresent(interp, _jsi_STACKIDX(interp->framePtr->Sp-3), io->keys[io->iter],1))
break;
} else {
while (io->cur < io->obj->arrCnt) {
if (io->obj->arr[io->cur]) break;
io->cur++;
}
if (io->cur >= io->obj->arrCnt) {
/* TODO: Is this really a bug??? */
/* Jsi_LogBug("NOT FOUND LIST ARRAY");*/
io->iter = io->count;
break;
} else if (io->obj->arr[io->cur]) {
io->cur++;
break;
}
}
io->iter++;
}
if (io->iter >= io->count) {
jsiClearStack(interp,1);
Jsi_ValueMakeNumber(interp, &_jsi_TOP, 0);
} else {
Jsi_Value **vPtr = &_jsi_TOP->d.lval, *v = *vPtr;
SIGASSERT(v, VALUE);
Jsi_ValueReset(interp, vPtr);
if (io->isArrayList) {
if (!io->isof)
Jsi_ValueMakeNumber(interp, &v, io->cur-1);
else if (!io->obj->arr[io->cur-1])
Jsi_ValueMakeNull(interp, &v);
else
Jsi_ValueCopy(interp, v, io->obj->arr[io->cur-1]);
} else
Jsi_ValueMakeStringKey(interp, &v, io->keys[io->iter]);
io->iter++;
jsiClearStack(interp,1);
Jsi_ValueMakeNumber(interp, &_jsi_TOP, 1);
}
break;
}
}
case OP_INC:
case OP_DEC: {
int inc = ip->op == OP_INC ? 1 : -1;
if (_jsi_TOP->vt != JSI_VT_VARIABLE) {
rc = Jsi_LogError("operand not left value");
break;
}
Jsi_Value *v = _jsi_TOP->d.lval;
SIGASSERT(v, VALUE);
Jsi_ValueToNumber(interp, v);
rc = _jsi_StrictChk(v);
v->d.num += inc;
jsiVarDeref(interp,1);
if (ip->data) {
_jsi_TOP->d.num -= inc;
}
break;
}
case OP_TYPEOF: {
const char *typ;
Jsi_Value *v = _jsi_TOP;
if (v->vt == JSI_VT_VARIABLE) {
v = v->d.lval;
SIGASSERT(v, VALUE);
}
typ = Jsi_ValueTypeStr(interp, v);
jsiVarDeref(interp,1);
Jsi_ValueMakeStringKey(interp, &_jsi_TOP, (char*)typ);
break;
}
case OP_INSTANCEOF: {
jsiVarDeref(interp,2);
int bval = Jsi_ValueInstanceOf(interp, _jsi_TOQ, _jsi_TOP);
jsiPop(interp,1);
Jsi_ValueMakeBool(interp, &_jsi_TOP, bval);
break;
}
case OP_JTRUE:
case OP_JFALSE:
case OP_JTRUE_NP:
case OP_JFALSE_NP: {
jsiVarDeref(interp,1);
int off = (uintptr_t)ip->data - 1;
int r = Jsi_ValueIsTrue(interp, _jsi_TOP);
if (ip->op == OP_JTRUE || ip->op == OP_JFALSE) jsiPop(interp,1);
ip += ((ip->op == OP_JTRUE || ip->op == OP_JTRUE_NP) ^ r) ? 0 : off;
break;
}
case OP_JMPPOP:
jsiPop(interp, ((jsi_JmpPopInfo *)ip->data)->topop);
case OP_JMP: {
int off = (ip->op == OP_JMP ? (uintptr_t)ip->data - 1
: (uintptr_t)((jsi_JmpPopInfo *)ip->data)->off - 1);
while (1) {
if (trylist == NULL) break;
jsi_OpCode *tojmp = ip + off;
/* jmp out of a try block, should execute the finally block */
/* while jmp out a 'with' block, restore the scope */
if (trylist->type == jsi_TL_TRY) {
if (tojmp >= trylist->d.td.tstart && tojmp < trylist->d.td.fend) break;
if (ip >= trylist->d.td.tstart && ip < trylist->d.td.cend) {
trylist->d.td.last_op = jsi_LOP_JMP;
trylist->d.td.ld.tojmp = tojmp;
ip = trylist->d.td.fstart - 1;
off = 0;
break;
} else if (ip >= trylist->d.td.fstart && ip < trylist->d.td.fend) {
pop_try(trylist);
} else Jsi_LogBug("jmp within a try, but not in its scope?");
} else {
/* with block */
if (tojmp >= trylist->d.wd.wstart && tojmp < trylist->d.wd.wend) break;
JSI_RESTORE_SCOPE();
pop_try(trylist);
}
}
ip += off;
break;
}
case OP_EVAL: {
int stackargc = (uintptr_t)ip->data;
jsiVarDeref(interp, stackargc);
int r = 0;
Jsi_Value *spPtr = Jsi_ValueNew1(interp);
if (stackargc > 0) {
if (_jsi_STACKIDX(interp->framePtr->Sp - stackargc)->vt == JSI_VT_UNDEF) {
Jsi_LogError("undefined value to eval()");
goto undef_eval;
}
int plen;
char *pro = Jsi_ValueString(interp, _jsi_STACKIDX(interp->framePtr->Sp - stackargc), &plen);
if (pro) {
pro = Jsi_StrdupLen(pro, plen);
r = jsiEvalOp(interp, ps, pro, scope, currentScope, _this, &spPtr);
Jsi_Free(pro);
} else {
Jsi_ValueCopy(interp, spPtr, _jsi_STACKIDX(interp->framePtr->Sp - stackargc));
}
}
undef_eval:
jsiPop(interp, stackargc);
Jsi_ValueCopy(interp, _jsi_STACK[interp->framePtr->Sp], spPtr); /*TODO: is this correct?*/
Jsi_DecrRefCount(interp, spPtr);
jsiPush(interp,1);
if (r) {
JSI_DO_THROW("eval");
}
break;
}
case OP_RET: {
if (interp->framePtr->Sp>=1 && ip->data) {
jsiVarDeref(interp,1);
Jsi_ValueMove(interp, vret, _jsi_TOP);
}
jsiPop(interp, (uintptr_t)ip->data);
interp->didReturn = 1;
if (trylist) {
while (trylist) {
if (trylist->type == jsi_TL_TRY && trylist->inCatch)
JSI_RESTORE_SCOPE();
pop_try(trylist);
}
goto done;
}
ip = end;
break;
}
case OP_DELETE: {
int count = (uintptr_t)ip->data;
if (count == 1) { // Non-standard.
if (_jsi_TOP->vt != JSI_VT_VARIABLE)
rc = Jsi_LogError("delete a right value");
else {
Jsi_Value **vPtr = &_jsi_TOP->d.lval, *v = *vPtr;
SIGASSERT(v, VALUE);
if (v->f.bits.dontdel) {
if (strict) rc = Jsi_LogWarn("delete not allowed");
} else if (v != currentScope) {
Jsi_ValueReset(interp,vPtr); /* not allow to delete arguments */
}
else if (strict)
Jsi_LogWarn("Delete arguments");
}
jsiPop(interp,1);
} else if (count == 2) {
jsiVarDeref(interp,2);
assert(interp->framePtr->Sp>=2);
if (strict) {
if (_jsi_TOQ->vt != JSI_VT_OBJECT) Jsi_LogWarn("delete non-object key, ignore");
if (_jsi_TOQ->d.obj == currentScope->d.obj) Jsi_LogWarn("Delete arguments");
}
jsi_ValueObjDelete(interp, _jsi_TOQ, _jsi_TOP, 0);
jsiPop(interp,2);
} else Jsi_LogBug("delete");
break;
}
case OP_OBJECT: {
int itemcount = (uintptr_t)ip->data;
Assert(itemcount>=0);
jsiVarDeref(interp, itemcount * 2);
Jsi_Obj *obj = Jsi_ObjNewObj(interp, _jsi_STACK+(interp->framePtr->Sp-itemcount*2), itemcount*2);
jsiPop(interp, itemcount * 2 - 1); /* one left */
jsiClearStack(interp,1);
Jsi_ValueMakeObject(interp, &_jsi_TOP, obj);
break;
}
case OP_ARRAY: {
int itemcount = (uintptr_t)ip->data;
Assert(itemcount>=0);
jsiVarDeref(interp, itemcount);
Jsi_Obj *obj = Jsi_ObjNewArray(interp, _jsi_STACK+(interp->framePtr->Sp-itemcount), itemcount, 1);
jsiPop(interp, itemcount - 1);
jsiClearStack(interp,1);
Jsi_ValueMakeObject(interp, &_jsi_TOP, obj);
break;
}
case OP_STRY: {
jsi_TryInfo *ti = (jsi_TryInfo *)ip->data;
jsi_TryList *n = jsi_trylist_new(jsi_TL_TRY, scope, currentScope);
n->d.td.tstart = ip; /* make every thing pointed to right pos */
n->d.td.tend = n->d.td.tstart + ti->trylen;
n->d.td.cstart = n->d.td.tend + 1;
n->d.td.cend = n->d.td.tend + ti->catchlen;
n->d.td.fstart = n->d.td.cend + 1;
n->d.td.fend = n->d.td.cend + ti->finallen;
n->d.td.tsp = interp->framePtr->Sp;
n->inCatch=0;
n->inFinal=0;
jsi_push_try(interp, &trylist, n);
break;
}
case OP_ETRY: { /* means nothing happen go to final */
if (trylist == NULL || trylist->type != jsi_TL_TRY)
Jsi_LogBug("Unexpected ETRY opcode??");
ip = trylist->d.td.fstart - 1;
break;
}
case OP_SCATCH: {
if (trylist == NULL || trylist->type != jsi_TL_TRY)
Jsi_LogBug("Unexpected SCATCH opcode??");
if (!ip->data) {
JSI_DO_THROW("catch");
} else {
trylist->inCatch=1;
/* new scope and make var */
scope = jsi_ScopeChainDupNext(interp, scope, currentScope);
currentScope = jsi_ObjValueNew(interp);
interp->framePtr->ingsc = scope; //TODO: changing frame
interp->framePtr->incsc = currentScope;
Jsi_IncrRefCount(interp, currentScope);
Jsi_Value *excpt = Jsi_ValueNew1(interp);
if (ps->last_exception && ps->last_exception->vt != JSI_VT_UNDEF) {
//TODO: fix test262 crash in freeValueTbl@jsiInterp.c:565 for last_exception which is
// freed in jsi_PstateFree@jsiPstate.c:251. Is this code the problem?
Jsi_Value *ple = ps->last_exception;
Jsi_ValueCopy(interp, excpt, ple);
Jsi_ValueReset(interp, &ps->last_exception);
} else if (interp->errMsgBuf[0]) {
Jsi_ValueMakeStringDup(interp, &excpt, interp->errMsgBuf);
interp->errMsgBuf[0] = 0;
}
Jsi_ValueInsert(interp, currentScope, (char*)ip->data, excpt, JSI_OM_DONTENUM);
Jsi_DecrRefCount(interp, excpt);
context_id = ps->_context_id++;
}
break;
}
case OP_ECATCH: {
if (trylist == NULL || trylist->type != jsi_TL_TRY)
Jsi_LogBug("Unexpected ECATCH opcode??");
trylist->inCatch=0;
ip = trylist->d.td.fstart - 1;
break;
}
case OP_SFINAL: {
if (trylist == NULL || trylist->type != jsi_TL_TRY)
Jsi_LogBug("Unexpected SFINAL opcode??");
/* restore scatch scope chain */
trylist->inFinal = 1;
JSI_RESTORE_SCOPE();
break;
}
case OP_EFINAL: {
if (trylist == NULL || trylist->type != jsi_TL_TRY)
Jsi_LogBug("Unexpected EFINAL opcode??");
trylist->inFinal = 0;
int last_op = trylist->d.td.last_op;
jsi_OpCode *tojmp = (last_op == jsi_LOP_JMP ? trylist->d.td.ld.tojmp : 0);
pop_try(trylist);
if (last_op == jsi_LOP_THROW) {
JSI_DO_THROW("finally");
} else if (last_op == jsi_LOP_JMP) {
while (1) {
if (trylist == NULL) {
ip = tojmp;
break;
}
/* same as jmp opcode, see above */
if (trylist->type == jsi_TL_TRY) {
if (tojmp >= trylist->d.td.tstart && tojmp < trylist->d.td.fend) {
ip = tojmp;
break;
}
if (ip >= trylist->d.td.tstart && ip < trylist->d.td.cend) {
trylist->d.td.last_op = jsi_LOP_JMP;
trylist->d.td.ld.tojmp = tojmp;
ip = trylist->d.td.fstart - 1;
break;
} else if (ip >= trylist->d.td.fstart && ip < trylist->d.td.fend) {
pop_try(trylist);
} else Jsi_LogBug("jmp within a try, but not in its scope?");
} else { /* 'with' block */
if (tojmp >= trylist->d.wd.wstart && tojmp < trylist->d.wd.wend) {
ip = tojmp;
break;
}
JSI_RESTORE_SCOPE();
pop_try(trylist);
}
}
}
break;
}
case OP_THROW: {
jsiVarDeref(interp,1);
Jsi_ValueDup2(interp,&ps->last_exception, _jsi_TOP);
interp->didReturn = 1; /* TODO: could possibly hide _jsi_STACK problem */
JSI_DO_THROW("throw");
break;
}
case OP_WITH: {
static int warnwith = 1;
if (strict && warnwith && interp->typeCheck.nowith) {
warnwith = 0;
rc = Jsi_LogError("use of with is illegal due to \"use nowith\"");
break;
}
jsiVarDeref(interp,1);
Jsi_ValueToObject(interp, _jsi_TOP);
jsi_TryList *n = jsi_trylist_new(jsi_TL_WITH, scope, currentScope);
n->d.wd.wstart = ip;
n->d.wd.wend = n->d.wd.wstart + (uintptr_t)ip->data;
jsi_push_try(interp, &trylist, n);
interp->framePtr->withDepth++;
/* make expr to top of scope chain */
scope = jsi_ScopeChainDupNext(interp, scope, currentScope);
currentScope = Jsi_ValueNew1(interp);
interp->framePtr->ingsc = scope;
interp->framePtr->incsc = currentScope;
Jsi_ValueCopy(interp, currentScope, _jsi_TOP);
jsiPop(interp,1);
context_id = ps->_context_id++;
break;
}
case OP_EWITH: {
if (trylist == NULL || trylist->type != jsi_TL_WITH)
Jsi_LogBug("Unexpected EWITH opcode??");
JSI_RESTORE_SCOPE();
pop_try(trylist);
interp->framePtr->withDepth--;
break;
}
case OP_DEBUG: {
jsi_DebuggerStmt();
jsiPush(interp,1);
break;
}
case OP_RESERVED: {
jsi_ReservedInfo *ri = (jsi_ReservedInfo *)ip->data;
const char *cmd = ri->type == RES_CONTINUE ? "continue" : "break";
/* TODO: continue/break out of labeled scope: see tests/prob/break.jsi. */
if (ri->label) {
Jsi_LogError("%s: label(%s) not found", cmd, ri->label);
} else {
Jsi_LogError("%s must be inside loop(or switch)", cmd);
}
rc = JSI_ERROR;
break;
}
#ifndef __cplusplus
default:
Jsi_LogBug("invalid op ceod: %d", ip->op);
#endif
}
lop = plop;
ip++;
}
done:
while (trylist) {
JSI_RESTORE_SCOPE();
pop_try(trylist);
}
return rc;
}
|
CWE-120
| null | 520,634 |
201292000531041697140495503933193370341
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void SwapNodes(Jsi_TreeEntry* n, Jsi_TreeEntry* m)
{
Jsi_Tree* t = n->treePtr;
Jsi_TreeEntry *np, *nl, *nr, *mp, *ml, *mr;
int mpc = 0, npc = 0, col = n->f.bits.color;
n->f.bits.color = m->f.bits.color; m->f.bits.color = col;
np = n->parent; nl = n->left; nr = n->right;
mp = m->parent; ml = m->left; mr = m->right;
if (mp) mpc = (mp->left == m ?1 : 2);
if (np) npc = (np->left == n ?1 : 2);
n->parent = mp; n->left = ml; n->right = mr;
m->parent = np; m->left = nl; m->right = nr;
if (np == m) {
m->parent = n;
if (mr == n) n->right = m; else n->left = m;
} else if (mp == n) {
n->parent = m;
if (nr == m) m->right = n; else m->left = n;
}
/* Fixup back pointers. */
if (m->left) m->left->parent = m;
if (m->right) m->right->parent = m;
if (n->left) n->left->parent = n;
if (n->right) n->right->parent = n;
if (mpc) { if (mpc==1) n->parent->left = n; else n->parent->right = n;}
if (npc) { if (npc==1) m->parent->left = m; else m->parent->right = m; }
if (n->parent == NULL) {
t->root = n;
} else if (m->parent == NULL) {
t->root = m;
}
}
|
CWE-120
| null | 520,635 |
18945530825995206314481069803374738477
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_HashEntryFind( Jsi_Hash *tablePtr, const void *key)
{
if (tablePtr->opts.lockHashProc && (*tablePtr->opts.lockHashProc)(tablePtr, 1) != JSI_OK)
return NULL;
Jsi_HashEntry *hPtr = (*((tablePtr)->findProc))(tablePtr, key);
if (tablePtr->opts.lockHashProc)
(*tablePtr->opts.lockHashProc)(tablePtr, 0);
return hPtr;
}
|
CWE-120
| null | 520,636 |
207714711615884561405845084397329535939
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_push_num(Jsi_Number *v) { JSI_NEW_CODES(1,OP_PUSHNUM, v); }
|
CWE-120
| null | 520,637 |
108372333561363239574303756412957523455
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueNewBlob(Jsi_Interp *interp, unsigned char *s, uint len) {
Jsi_Value *v = Jsi_ValueNew(interp);
Jsi_Obj *o = Jsi_ObjNewType(interp, JSI_OT_STRING);
Jsi_ValueMakeObject(interp, &v, o);
o->d.s.str = (char*)Jsi_Malloc(len+1);
memcpy(o->d.s.str, (char*)s, len);
o->d.s.str[len] = 0;
o->d.s.len = len;
o->isBlob = 1;
return v;
}
|
CWE-120
| null | 520,638 |
272365514469228573791158588686747560312
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_NumberIsNaN(Jsi_Number n)
{
return isnan(n);
}
|
CWE-120
| null | 520,639 |
271371693161553267281638721036540833092
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int OneWordCompare(Jsi_Tree *treePtr, const void *key1, const void *key2)
{
return ((uintptr_t )key1 - (uintptr_t)key2);
}
|
CWE-120
| null | 520,640 |
137589974377980409909362070987477781784
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_ValueGetNumber(Jsi_Interp *interp, Jsi_Value *pv, Jsi_Number *val)
{
if (!pv) return JSI_ERROR;
if (pv->vt == JSI_VT_NUMBER)
*val = pv->d.num;
else if (pv->vt == JSI_VT_OBJECT && pv->d.obj->ot == JSI_OT_NUMBER)
*val = pv->d.obj->d.num;
else
return JSI_ERROR;
return JSI_OK;
}
|
CWE-120
| null | 520,641 |
114498144977754878037962691940811218922
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_GlobMatch(const char *pattern, const char *string, int nocase)
{
int c;
int pchar;
while (*pattern) {
switch (pattern[0]) {
case '*':
while (pattern[1] == '*') {
pattern++;
}
pattern++;
if (!pattern[0]) {
return 1; /* match */
}
while (*string) {
if (Jsi_GlobMatch(pattern, string, nocase))
return 1; /* match */
string += Jsi_UtfToUniChar(string, &c);
}
return 0; /* no match */
case '?':
string += Jsi_UtfToUniChar(string, &c);
break;
case '[': {
string += Jsi_UtfToUniChar(string, &c);
pattern = JsiCharsetMatch(pattern + 1, c, nocase ? JSI_CMP_NOCASE : 0);
if (!pattern) {
return 0;
}
if (!*pattern) {
/* Ran out of pattern (no ']') */
continue;
}
break;
}
case '\\':
if (pattern[1]) {
pattern++;
}
/* fall through */
default:
string += Jsi_UtfToUniCharCase(string, &c, nocase);
Jsi_UtfToUniCharCase(pattern, &pchar, nocase);
if (pchar != c) {
return 0;
}
break;
}
pattern += Jsi_UtfToUniCharCase(pattern, &pchar, nocase);
if (!*string) {
while (*pattern == '*') {
pattern++;
}
break;
}
}
if (!*pattern && !*string) {
return 1;
}
return 0;
}
|
CWE-120
| null | 520,642 |
31162096474335233323910594641219917450
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static const char **jsi_OptGetEnumList(Jsi_OptionSpec* spec) {
const char **list = (const char**)spec->data;
Jsi_OptionSpec* es=NULL;
int fflags = (spec->flags);
if (spec->id != JSI_OPTION_CUSTOM || spec->custom != Jsi_Opt_SwitchEnum)
return list;
if (list && (fflags & JSI_OPT_ENUM_SPEC)) {
es = (typeof(es))list;
while (es->id != JSI_OPTION_END)
es++;
list = es->init.STRKEY;
}
return list;
}
|
CWE-120
| null | 520,643 |
278154619788104607032357832054632967074
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_ValueObjGetKeys(Jsi_Interp *interp, Jsi_Value *target, Jsi_Value *ret, bool isof)
{
Jsi_IterObj *io = Jsi_IterObjNew(interp, NULL);
Jsi_Obj *to = target->d.obj;
if (target->vt != JSI_VT_UNDEF && target->vt != JSI_VT_NULL) {
if (target->vt == JSI_VT_OBJECT && to->arr) {
io->isArrayList = 1;
io->count = to->arrCnt;
} else {
if (isof &&interp->strict)
Jsi_LogWarn("non-array in 'for...of'");
Jsi_IterGetKeys(interp, target, io, 0);
}
}
io->obj = to;
io->isof = isof;
Jsi_Obj *r = Jsi_ObjNew(interp);
r->ot = JSI_OT_ITER;
r->d.iobj = io;
Jsi_ValueMakeObject(interp, &ret, r);
}
|
CWE-120
| null | 520,644 |
117689617099391979615011935770680105871
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_OptionsDump(Jsi_Interp *interp, Jsi_OptionSpec *specs, void *rec, Jsi_Value **ret, Jsi_Wide flags)
{
char *record = (char*)rec;
Jsi_OptionSpec *specPtr = specs;
int len = 0, i = 0, count = 0;
if (!Jsi_OptionsValid(interp, specs))
return Jsi_LogError("invalid options");
while (specPtr->id>=JSI_OPTION_BOOL && specPtr->id < JSI_OPTION_END && specPtr->name) {
specPtr++;
len+=2;
}
if (!len)
return JSI_OK;
Jsi_Value *rv = Jsi_ValueMakeObject(interp, NULL, NULL);
Jsi_IncrRefCount(interp, rv);
Jsi_Obj *obj = rv->d.obj;
specPtr = specs;
while (specPtr->id>=JSI_OPTION_BOOL && specPtr->id < JSI_OPTION_END && specPtr->name) {
Jsi_Value *vv = Jsi_ValueNew1(interp);
if (jsi_GetOption(interp, specPtr, record, NULL, &vv, flags) != JSI_OK) {
Jsi_DecrRefCount(interp, vv);
Jsi_DecrRefCount(interp, rv);
return JSI_ERROR;
}
if (flags&JSI_OPTS_VERBOSE) {
// dump: id,value,help,info,init
Jsi_Value *vrv = Jsi_ValueMakeObject(interp, NULL, NULL);
Jsi_IncrRefCount(interp, vrv);
Jsi_Obj *vobj = vrv->d.obj;
Jsi_ObjInsert(interp, vobj, "value", vv, 0);
Jsi_DecrRefCount(interp, vv);
vv = vrv;
jsi_DumpOptionSpec(interp, vobj, specPtr, 0);
}
Jsi_ObjInsert(interp, obj, specPtr->name, vv, 0);
Jsi_DecrRefCount(interp, vv);
count++;
i++;
specPtr++;
}
assert(specPtr->id == JSI_OPTION_END);
Jsi_ValueReplace(interp, ret, rv);
Jsi_DecrRefCount(interp, rv);
return JSI_OK;
}
|
CWE-120
| null | 520,645 |
15463764145920095169214394769285020405
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void interpObjErase(InterpObj *fo)
{
SIGASSERTV(fo,INTERPOBJ);
if (fo->subinterp) {
Jsi_Interp *interp = fo->subinterp;
fo->subinterp = NULL;
Jsi_InterpDelete(interp);
/*fclose(fo->fp);
Jsi_Free(fo->interpname);
Jsi_Free(fo->mode);*/
}
fo->subinterp = NULL;
}
|
CWE-120
| null | 520,646 |
313266174047533415593311204602360594414
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_HashFree(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
Jsi_Free(ptr);
return JSI_OK;
}
|
CWE-120
| null | 520,647 |
45773502103063028972124681646629801014
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_CleanValue(Jsi_Interp *interp, Jsi_Interp *tointerp, Jsi_Value *val, Jsi_Value **ret)
{
Jsi_RC rc = JSI_OK;
const char *cp;
int len, iskey;
Jsi_Obj *obj;
switch (val->vt) {
case JSI_VT_UNDEF: Jsi_ValueMakeUndef(interp, ret); return rc;
case JSI_VT_NULL: Jsi_ValueMakeNull(tointerp, ret); return rc;
case JSI_VT_BOOL: Jsi_ValueMakeBool(tointerp, ret, val->d.val); return rc;
case JSI_VT_NUMBER: Jsi_ValueMakeNumber(tointerp, ret, val->d.num); return rc;
case JSI_VT_STRING:
iskey = val->f.bits.isstrkey;
cp = val->d.s.str;
len = val->d.s.len;
makestr:
if (iskey) {
Jsi_ValueMakeStringKey(interp, ret, cp);
return rc;
}
jsi_ValueMakeBlobDup(tointerp, ret, (uchar*)cp, len);
return rc;
case JSI_VT_OBJECT:
obj = val->d.obj;
switch (obj->ot) {
case JSI_OT_BOOL: Jsi_ValueMakeBool(tointerp, ret, obj->d.val); return rc;
case JSI_OT_NUMBER: Jsi_ValueMakeNumber(tointerp, ret, obj->d.num); return rc;
case JSI_OT_STRING:
cp = obj->d.s.str;
len = obj->d.s.len;
iskey = obj->isstrkey;
goto makestr;
default: break;
}
break;
default:
break;
}
Jsi_DString dStr;
Jsi_DSInit(&dStr);
cp = Jsi_ValueGetDString(interp, val, &dStr, JSI_OUTPUT_JSON);
if (Jsi_JSONParse(tointerp, cp, ret, 0) != JSI_OK) {
Jsi_DSFree(&dStr);
return Jsi_LogWarn("bad JSON parse in subinterp");
}
Jsi_DSFree(&dStr);
return rc;
}
|
CWE-120
| null | 520,648 |
115565094119350364050264698582383748412
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_NumberIsWide(Jsi_Number n) { return (isnormal(n) && (Jsi_Number)((Jsi_Wide)(n)) == (n)); }
|
CWE-120
| null | 520,649 |
44234055242186203803402942372757001429
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_TreeWalk(Jsi_Tree* treePtr, Jsi_TreeWalkProc* callback, void *data, int flags) {
Jsi_Interp *interp = treePtr->opts.interp;
JSI_NOTUSED(interp);
int n = 0, m = -1, lastm, order;
order = flags & JSI_TREE_ORDER_MASK;
switch (order) {
case JSI_TREE_ORDER_PRE:
return tree_preorder(treePtr, treePtr->root, callback, data);
case JSI_TREE_ORDER_POST:
return tree_postorder(treePtr, treePtr->root, callback, data);
case JSI_TREE_ORDER_IN:
return tree_inorder(treePtr, treePtr->root, callback, data);
case JSI_TREE_ORDER_LEVEL:
while (1) {
lastm = m;
if (tree_levelorder(treePtr, treePtr->root, callback, data, 0, n, &m) != JSI_OK)
return JSI_ERROR;
if (lastm == m)
return JSI_OK;
n++;
}
default:
Jsi_LogError("Invalid order: %d", order);
}
return JSI_ERROR;
}
|
CWE-120
| null | 520,650 |
88571780360905212767989031336453824040
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC mdbStmtFreeProc(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *value) {
MySqlObj *jdb = (MySqlObj*)interp;
Jsi_ListEntry *l = (Jsi_ListEntry*)hPtr;
mdbRelease1Stmt(jdb, (MysqlPrep*)Jsi_ListValueGet(l));
return JSI_OK;
}
|
CWE-120
| null | 520,651 |
95478672111279763535743019649660487431
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsiObjGetNames(Jsi_Interp *interp, Jsi_Obj *obj, Jsi_DString* dStr, int flags) {
Jsi_TreeEntry *hPtr;
Jsi_TreeSearch srch;
Jsi_Value *v;
int m = 0;
Jsi_DSInit(dStr);
if (obj->isarrlist)
obj = interp->Array_prototype->d.obj;
else if (!obj->tree->numEntries && obj->__proto__)
obj = obj->__proto__->d.obj;
for (hPtr=Jsi_TreeSearchFirst(obj->tree, &srch, JSI_TREE_ORDER_IN, NULL); hPtr; hPtr=Jsi_TreeSearchNext(&srch)) {
v = (Jsi_Value*)Jsi_TreeValueGet(hPtr);
if (!v) continue;
if ((flags&JSI_NAME_FUNCTIONS) && !Jsi_ValueIsFunction(interp,v)) {
continue;
}
if ((flags&JSI_NAME_DATA) && Jsi_ValueIsFunction(interp,v)) {
continue;
}
Jsi_DSAppend(dStr, (m++?" ":""), Jsi_TreeKeyGet(hPtr), NULL);
}
Jsi_TreeSearchDone(&srch);
}
|
CWE-120
| null | 520,652 |
96785692548886608627285070499640961152
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC NumberToFixedCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
char buf[JSI_MAX_NUMBER_STRING+1];
int prec = 0, skip = 0;
Jsi_Number num;
Jsi_Value *v;
ChkStringN(_this, funcPtr, v);
Jsi_Value *pa = Jsi_ValueArrayIndex(interp, args, skip);
if (pa && Jsi_GetIntFromValue(interp, pa, &prec) != JSI_OK)
return JSI_ERROR;
if (prec<0) prec = 0;
Jsi_GetDoubleFromValue(interp, v, &num);
snprintf(buf, sizeof(buf), "%.*" JSI_NUMFFMT, prec, num);
Jsi_ValueMakeStringDup(interp, ret, buf);
return JSI_OK;
}
|
CWE-120
| null | 520,653 |
48590966149117788083565706845570313155
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int codes_insertln(Jsi_OpCodes *c, jsi_Eopcode code, void *extra, jsi_Pstate *pstate, jsi_Pline *line, int doalloc)
{
if (c->code_size - c->code_len <= 0) {
c->code_size += 100;
c->codes = (jsi_OpCode *)Jsi_Realloc(c->codes, c->code_size * sizeof(jsi_OpCode));
}
c->codes[c->code_len].op = code;
c->codes[c->code_len].data = extra;
c->codes[c->code_len].Line = line->first_line;
c->codes[c->code_len].Lofs = line->first_column;
c->codes[c->code_len].fname = jsi_PstateGetFilename(pstate);
c->codes[c->code_len].alloc = doalloc;
c->code_len ++;
return 0;
}
|
CWE-120
| null | 520,654 |
141977894814149811231456229055150336445
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_TreeEntry * Jsi_ObjInsert(Jsi_Interp *interp, Jsi_Obj *obj, const char *key, Jsi_Value *val, int flags)
{
Jsi_TreeEntry *hPtr;
SIGASSERT(val, VALUE);
/*if (val)
Jsi_IncrRefCount(interp, val);*/
hPtr = Jsi_TreeObjSetValue(obj, key, val, (flags&JSI_OM_ISSTRKEY));
if ((flags&JSI_OM_DONTDEL))
val->f.bits.dontdel = hPtr->f.bits.dontdel = 1;
if ((flags&JSI_OM_READONLY))
val->f.bits.readonly =hPtr->f.bits.readonly = 1;
if ((flags&JSI_OM_DONTENUM))
val->f.bits.dontenum =hPtr->f.bits.dontenum = 1;
return hPtr;
}
|
CWE-120
| null | 520,655 |
45784704009729442584701393316853857341
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC packageHashFree(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
jsi_PkgInfo *p = (jsi_PkgInfo*)ptr;
if (p->popts.info) Jsi_DecrRefCount(interp, p->popts.info);
Jsi_Free(p);
return JSI_OK;
}
|
CWE-120
| null | 520,656 |
160994468507733772876680777075413815231
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int dbAuthCallback(
void *pArg,
int code,
const char *zArg1,
const char *zArg2,
const char *zArg3,
const char *zArg4
) {
const char *zCode;
int rc;
const char *zReply;
Jsi_Db *jdb = (Jsi_Db*)pArg;
Jsi_Interp *interp = jdb->interp;
if( jdb->disableAuth ) return SQLITE_OK;
switch( code ) {
case SQLITE_COPY :
zCode="SQLITE_COPY";
break;
case SQLITE_CREATE_INDEX :
zCode="SQLITE_CREATE_INDEX";
break;
case SQLITE_CREATE_TABLE :
zCode="SQLITE_CREATE_TABLE";
break;
case SQLITE_CREATE_TEMP_INDEX :
zCode="SQLITE_CREATE_TEMP_INDEX";
break;
case SQLITE_CREATE_TEMP_TABLE :
zCode="SQLITE_CREATE_TEMP_TABLE";
break;
case SQLITE_CREATE_TEMP_TRIGGER:
zCode="SQLITE_CREATE_TEMP_TRIGGER";
break;
case SQLITE_CREATE_TEMP_VIEW :
zCode="SQLITE_CREATE_TEMP_VIEW";
break;
case SQLITE_CREATE_TRIGGER :
zCode="SQLITE_CREATE_TRIGGER";
break;
case SQLITE_CREATE_VIEW :
zCode="SQLITE_CREATE_VIEW";
break;
case SQLITE_DELETE :
zCode="SQLITE_DELETE";
break;
case SQLITE_DROP_INDEX :
zCode="SQLITE_DROP_INDEX";
break;
case SQLITE_DROP_TABLE :
zCode="SQLITE_DROP_TABLE";
break;
case SQLITE_DROP_TEMP_INDEX :
zCode="SQLITE_DROP_TEMP_INDEX";
break;
case SQLITE_DROP_TEMP_TABLE :
zCode="SQLITE_DROP_TEMP_TABLE";
break;
case SQLITE_DROP_TEMP_TRIGGER :
zCode="SQLITE_DROP_TEMP_TRIGGER";
break;
case SQLITE_DROP_TEMP_VIEW :
zCode="SQLITE_DROP_TEMP_VIEW";
break;
case SQLITE_DROP_TRIGGER :
zCode="SQLITE_DROP_TRIGGER";
break;
case SQLITE_DROP_VIEW :
zCode="SQLITE_DROP_VIEW";
break;
case SQLITE_INSERT :
zCode="SQLITE_INSERT";
break;
case SQLITE_PRAGMA :
zCode="SQLITE_PRAGMA";
break;
case SQLITE_READ :
zCode="SQLITE_READ";
break;
case SQLITE_SELECT :
zCode="SQLITE_SELECT";
break;
case SQLITE_TRANSACTION :
zCode="SQLITE_TRANSACTION";
break;
case SQLITE_UPDATE :
zCode="SQLITE_UPDATE";
break;
case SQLITE_ATTACH :
zCode="SQLITE_ATTACH";
break;
case SQLITE_DETACH :
zCode="SQLITE_DETACH";
break;
case SQLITE_ALTER_TABLE :
zCode="SQLITE_ALTER_TABLE";
break;
case SQLITE_REINDEX :
zCode="SQLITE_REINDEX";
break;
case SQLITE_ANALYZE :
zCode="SQLITE_ANALYZE";
break;
case SQLITE_CREATE_VTABLE :
zCode="SQLITE_CREATE_VTABLE";
break;
case SQLITE_DROP_VTABLE :
zCode="SQLITE_DROP_VTABLE";
break;
case SQLITE_FUNCTION :
zCode="SQLITE_FUNCTION";
break;
case SQLITE_SAVEPOINT :
zCode="SQLITE_SAVEPOINT";
break;
default :
zCode="????";
break;
}
int i = 0;
Jsi_Value *vpargs, *items[10] = {}, *ret;
items[i++] = Jsi_ValueNewObj(interp, jdb->fobj);
items[i++] = Jsi_ValueMakeStringDup(interp, NULL, zCode);
items[i++] = Jsi_ValueMakeStringDup(interp, NULL, zArg1 ? zArg1 : "");
items[i++] = Jsi_ValueMakeStringDup(interp, NULL, zArg2 ? zArg2 : "");
items[i++] = Jsi_ValueMakeStringDup(interp, NULL, zArg3 ? zArg3 : "");
items[i++] = Jsi_ValueMakeStringDup(interp, NULL, zArg4 ? zArg4 : "");
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, items, i, 0));
Jsi_IncrRefCount(interp, vpargs);
ret = Jsi_ValueNew(interp);
rc = Jsi_FunctionInvoke(interp, jdb->onAuth, vpargs, &ret, NULL);
Jsi_DecrRefCount(interp, vpargs);
if (rc == JSI_OK && (zReply = Jsi_ValueGetStringLen(interp, ret, NULL)))
{
if( Jsi_Strcmp(zReply,"SQLITE_OK")==0 ) {
rc = SQLITE_OK;
} else if( Jsi_Strcmp(zReply,"SQLITE_DENY")==0 ) {
rc = SQLITE_DENY;
} else if( Jsi_Strcmp(zReply,"SQLITE_IGNORE")==0 ) {
rc = SQLITE_IGNORE;
} else {
rc = 999;
}
}
Jsi_DecrRefCount(interp, ret);
return rc;
}
|
CWE-120
| null | 520,657 |
43100519113280373436466990527465273937
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_FunctionReturnIgnored(Jsi_Interp *interp, Jsi_Func *funcPtr) {
return funcPtr->callflags.bits.isdiscard;
}
|
CWE-120
| null | 520,658 |
26536284865655989150434766227819847244
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_InterpGone( Jsi_Interp* interp)
{
return (interp == NULL || interp->deleting || interp->destroying || interp->exited);
}
|
CWE-120
| null | 520,659 |
48455492699642941194330563248286315535
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static MYSQL* mdbConnect(Jsi_Interp *interp, MySqlObj* jdb)
{
return mysql_real_connect(jdb->db,
jdb->host?Jsi_ValueString(interp, jdb->host, NULL):NULL,
jdb->user, jdb->password, jdb->database,
jdb->port, 0, jdb->dbflags);
}
|
CWE-120
| null | 520,660 |
339625550478444543028661411130620310011
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC KeyLockerTree(Jsi_Tree* tree, int lock) { return KeyLocker((Jsi_Hash*)tree, lock); }
|
CWE-120
| null | 520,661 |
11682590130026107567698965803627264463
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_evalcode(jsi_Pstate *ps, Jsi_Func *func, Jsi_OpCodes *opcodes,
jsi_ScopeChain *scope, Jsi_Value *fargs,
Jsi_Value *_this,
Jsi_Value **vret)
{
Jsi_Interp *interp = ps->interp;
if (interp->exited)
return JSI_ERROR;
Jsi_RC rc;
jsi_Frame frame = *interp->framePtr;
frame.parent = interp->framePtr;
interp->framePtr = &frame;
frame.parent->child = interp->framePtr = &frame;
frame.ps = ps;
frame.ingsc = scope;
frame.incsc = fargs;
frame.inthis = _this;
frame.opcodes = opcodes;
frame.fileName = ((func && func->script)?func->script:interp->curFile);
frame.funcName = interp->curFunction;
frame.dirName = interp->curDir;
if (frame.fileName && frame.fileName == frame.parent->fileName)
frame.logflag = frame.parent->logflag;
else
frame.logflag = 0;
frame.level = frame.parent->level+1;
frame.evalFuncPtr = func;
frame.arguments = NULL;
// if (func && func->strict)
// frame.strict = 1;
if (interp->curIp)
frame.parent->line = interp->curIp->Line;
frame.ip = interp->curIp;
interp->refCount++;
interp->level++;
Jsi_IncrRefCount(interp, fargs);
rc = jsi_evalcode_sub(ps, opcodes, scope, fargs, _this, *vret);
Jsi_DecrRefCount(interp, fargs);
if (interp->didReturn == 0 && !interp->exited && rc == JSI_OK) {
if ((interp->evalFlags&JSI_EVAL_RETURN)==0)
Jsi_ValueMakeUndef(interp, vret);
/*if (interp->framePtr->Sp != oldSp) //TODO: at some point after memory refs???
Jsi_LogBug("Stack not balance after execute script");*/
}
if (frame.arguments)
Jsi_DecrRefCount(interp, frame.arguments);
interp->didReturn = 0;
interp->refCount--;
interp->level--;
interp->framePtr = frame.parent;
interp->framePtr->child = NULL;
interp->curIp = frame.ip;
if (interp->exited)
rc = JSI_ERROR;
return rc;
}
|
CWE-120
| null | 520,662 |
210200427557188264923060675328508613829
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_push_func_sub(jsi_Pstate *p, jsi_Pline *line, Jsi_Func *fun) { p->funcDefs++; JSI_NEW_CODESLN(0,OP_PUSHFUN, fun); }
|
CWE-120
| null | 520,663 |
111518471215966570954174595677782845005
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
char *get_current_dir_name() {
static char buf[MAX_PATH] = ".";
getcwd(buf, sizeof(buf));
return buf;
}
|
CWE-120
| null | 520,664 |
114843391443602248832488987016896991813
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void* Jsi_CurrentThread(void) {
#ifdef __WIN32
return (void*)(uintptr_t)GetCurrentThreadId();
#else
return (void*)pthread_self();
#endif
}
|
CWE-120
| null | 520,665 |
8610541578918899240784291815255219835
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static const char *mdbFindEndStr(const char *cp) {
const char endc = *cp;
cp++;
while (*cp && *cp != endc) {
if (*cp == '\\' && cp[1]) cp++;
cp++;
}
if (*cp != endc)
return NULL;
return ++cp;
}
|
CWE-120
| null | 520,666 |
87663871439795520410166934477425189428
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void mdbClose(MYSQL *db) {
mysql_close(db);
}
|
CWE-120
| null | 520,667 |
71352546391850477419229804144156418528
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_InterpSetData(Jsi_Interp *interp, const char *key, void *data, Jsi_DeleteProc *proc)
{
bool isNew;
Jsi_HashEntry *hPtr;
AssocData *ptr;
hPtr = Jsi_HashEntryNew(interp->assocTbl, key, &isNew);
if (!hPtr)
return;
if (isNew) {
ptr = (AssocData *)Jsi_Calloc(1,sizeof(*ptr));
Jsi_HashValueSet(hPtr, ptr);
} else
ptr = (AssocData *)Jsi_HashValueGet(hPtr);
ptr->data = data;
ptr->delProc = proc;
}
|
CWE-120
| null | 520,668 |
262036406133505153103619827695295181420
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_pos() { JSI_NEW_CODES(0,OP_POS, 0); }
|
CWE-120
| null | 520,669 |
153490918891680119909628483469144016726
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC mysqlObjFree(Jsi_Interp *interp, void *data)
{
MySqlObj *jdb = (MySqlObj*)data;
SQLSIGASSERT(jdb,DB);
jdb->_->activeCnt--;
mysqlObjErase(jdb);
_JSI_MEMCLEAR(jdb);
Jsi_Free(jdb);
return JSI_OK;
}
|
CWE-120
| null | 520,670 |
90967884491775710845288094264238441174
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_VerifyToValue(Jsi_Interp *interp, Jsi_OptionSpec* spec, Jsi_Value **outValue, Jsi_DString *dStr, void *record, Jsi_Wide flags)
{
if (dStr)
return JSI_ERROR;
Jsi_Value **s = (Jsi_Value**)(((char*)record) + spec->offset);
if (*s)
Jsi_ValueReplace(interp, outValue, *s);
return JSI_OK;
}
|
CWE-120
| null | 520,671 |
128038986698377898530781503140333128891
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC RegexpExecCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
int skip = 0;
Jsi_Value *v;
ChkRegexp(_this, funcPtr, v);
/* TODO: add lastIndex support. */
int slen;
char *str = Jsi_ValueString(interp,Jsi_ValueArrayIndex(interp, args, skip), &slen);
if (!str)
return Jsi_LogError("expected string");
if (v == NULL || v->vt != JSI_VT_OBJECT || v->d.obj->ot != JSI_OT_REGEXP)
return Jsi_LogError("expected pattern");
Jsi_Regex *re = v->d.obj->d.robj;
int isglob = (re->eflags&JSI_REG_GLOB);
Jsi_Value *l = NULL;
Jsi_Number lv = 0;
if (isglob) {
l = Jsi_ValueObjLookup(interp, v, "lastIndex", 0);
if (l && Jsi_ValueGetNumber(interp, l, &lv) != JSI_OK)
return Jsi_LogError("lastIndex not a number");
if (l)
re->lastIndex = (int)lv;
}
int ofs = 0;
Jsi_RC rc = jsi_RegExpMatches(interp, v, re->lastIndex<slen?str+re->lastIndex:"", -1, *ret, isglob?&ofs:NULL, 0);
if (isglob) {
if (rc != JSI_OK)
return rc;
re->lastIndex += ofs;
if (Jsi_ValueIsNull(interp, *ret))
re->lastIndex = 0;
lv = (Jsi_Number)re->lastIndex;
if (!l)
Jsi_ValueInsert(interp, v, "lastIndex", Jsi_ValueNewNumber(interp, lv), JSI_OM_DONTDEL);
else if (l->vt == JSI_VT_NUMBER)
l->d.num = lv;
else if (l->vt == JSI_VT_OBJECT && l->d.obj->ot == JSI_OT_NUMBER)
l->d.obj->d.num = lv;
}
return rc;
}
|
CWE-120
| null | 520,672 |
177619448876190642521207553458772259323
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int jsi_FSScandirProc(Jsi_Interp *interp, Jsi_Value *path, Jsi_Dirent ***namelist,
int (*filter)(const Jsi_Dirent *), int (*compar)(const Jsi_Dirent **, const Jsi_Dirent**))
{
const char *dirname = Jsi_ValueToString(interp, path, NULL);
Jsi_DString dStr = {};
if (*dirname == '~')
dirname = jsi_TildePath(interp, dirname, &dStr);
int rc = scandir(dirname, namelist, filter, compar);
Jsi_DSFree(&dStr);
return rc;
}
|
CWE-120
| null | 520,673 |
299522578853217795288958306110277717152
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringConstructor(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
if (Jsi_FunctionIsConstructor(funcPtr)) {
const char *nv = "";
int len = -1;
if (Jsi_ValueGetLength(interp, args) > 0) {
Jsi_Value *v = Jsi_ValueArrayIndex(interp, args, 0);
if (v) {
nv = Jsi_ValueToString(interp, v, &len);
}
}
if (_this->vt == JSI_VT_OBJECT && _this->d.obj->ot == JSI_OT_STRING) {
if (_this->d.obj->d.s.str)
if (!_this->d.obj->isstrkey)
Jsi_Free(_this->d.obj->d.s.str);
_this->d.obj->isstrkey = 0;
_this->d.obj->d.s.str = Jsi_StrdupLen(nv, len);
_this->d.obj->d.s.len = len;
} else
jsi_ValueMakeBlobDup(interp, &_this, (uchar*)nv, len);
Jsi_ValueDup2(interp, ret, _this);
return JSI_OK;
}
if (Jsi_ValueGetLength(interp, args) > 0) {
Jsi_Value *v = Jsi_ValueArrayIndex(interp, args, 0);
if (v) {
Jsi_ValueDup2(interp, ret, v);
Jsi_ValueToString(interp, *ret, NULL);
return JSI_OK;
}
}
Jsi_ValueMakeStringDup(interp, ret, "");
return JSI_OK;
}
|
CWE-120
| null | 520,674 |
224583891129625773240663569603505510270
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_ValueGetBoolean(Jsi_Interp *interp, Jsi_Value *pv, bool *val)
{
if (!pv) return JSI_ERROR;
if (pv->vt == JSI_VT_BOOL)
*val = pv->d.val;
else if (pv->vt == JSI_VT_OBJECT && pv->d.obj->ot == JSI_OT_BOOL)
*val = pv->d.obj->d.val;
else
return JSI_ERROR;
return JSI_OK;
}
|
CWE-120
| null | 520,675 |
332627149873746392965741480691191710060
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_DeleteSpecCacheTable(Jsi_Interp *interp, void *clientData)
{
Jsi_Hash *tablePtr = (Jsi_Hash *) clientData;
Jsi_HashEntry *entryPtr;
Jsi_HashSearch search;
for (entryPtr = Jsi_HashSearchFirst(tablePtr,&search); entryPtr != NULL;
entryPtr = Jsi_HashSearchNext(&search)) {
Jsi_Free(Jsi_HashValueGet(entryPtr));
}
Jsi_HashDelete(tablePtr);
return JSI_OK;
}
|
CWE-120
| null | 520,676 |
327559825833808009073740134264249972245
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void dbOutputHexBlob(Jsi_DString *dStr, const void *pBlob, int nBlob){
int i;
char out[JSI_MAX_NUMBER_STRING], *zBlob = (char *)pBlob;
Jsi_DSAppend(dStr, "X'", NULL);
for(i=0; i<nBlob; i++){ snprintf(out, sizeof(out),"%02x",zBlob[i]&0xff);Jsi_DSAppend(dStr, out, NULL); }
Jsi_DSAppend(dStr, "'", NULL);
}
|
CWE-120
| null | 520,677 |
180880168672865901012535130373346384687
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_wsDumpQuery(jsi_wsCmdObj *cmdPtr, jsi_wsPss *pss, const char *name, Jsi_Value **ret)
{
int n = 0;
Jsi_Interp *interp = cmdPtr->interp;
Jsi_Obj *nobj;
Jsi_Value *nv;
if (!name) {
nobj = Jsi_ObjNewType(interp, JSI_OT_OBJECT);
Jsi_ValueMakeObject(interp, ret, nobj);
}
for (n = 0; n<pss->paramc; n++) {
const char *cp = lws_spa_get_string(pss->spa, n);
if (!cp) cp = "";
if (name) {
if (Jsi_Strcmp(name, pss->paramv[n])) { n++; continue; }
Jsi_ValueMakeStringDup(interp, ret, cp);
return;
}
nv = Jsi_ValueNewStringDup(interp, cp);
Jsi_ObjInsert(interp, nobj, pss->paramv[n], nv, 0);
}
}
|
CWE-120
| null | 520,678 |
228904088969575655145724000708147709521
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Puts(Jsi_Interp *interp, Jsi_Channel chan, const char *str, int size)
{
int code = 0, len = Jsi_Strlen(str);
if (chan->fsPtr==0 || !chan->fsPtr->putsProc) {
FILE *fp = (chan && chan->fp ? chan->fp : stdout);
code = fputs(str, fp);
} else {
if (interp && interp->debugOpts.putsCallback && interp->parent) {
int code = 0;
Jsi_DString jStr={}, kStr={};
Jsi_DSPrintf(&kStr, "[%s, %d]",
Jsi_JSONQuote(interp, str, size, &jStr), (chan->fp == stderr?1:0));
if (Jsi_FunctionInvokeJSON(interp->parent, interp->debugOpts.putsCallback, Jsi_DSValue(&kStr), NULL) != JSI_OK)
code = 1;
Jsi_DSFree(&jStr);
Jsi_DSFree(&kStr);
return code;
} else if (interp && interp->stdoutStr) {
Jsi_DString dStr = {};
Jsi_DSAppend(&dStr, Jsi_ValueString(interp, interp->stdoutStr, NULL), NULL);
Jsi_DSAppend(&dStr, str, NULL);
Jsi_ValueFromDS(interp, &dStr, &interp->stdoutStr);
} else
code = chan->fsPtr->putsProc(chan, str);
}
if (size>=0 && len < size) {
Jsi_Puts(interp, chan, "\\0", -1);
Jsi_Puts(interp, chan, str+len+1, size-len-1);
}
return code;
}
|
CWE-120
| null | 520,679 |
88129876625080813060741588574435548022
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueNew1(Jsi_Interp *interp) {
return ValueNew1(interp);
}
|
CWE-120
| null | 520,680 |
179153533826319977788025396801693989409
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_FuncObj *jsi_FuncObjNew(Jsi_Interp *interp, Jsi_Func *func)
{
Jsi_FuncObj *f = (Jsi_FuncObj*)Jsi_Calloc(1,sizeof(Jsi_FuncObj));
f->interp = interp;
SIGINIT(f,FUNCOBJ);
f->func = func;
func->refCnt++;
return f;
}
|
CWE-120
| null | 520,681 |
254572759799412768079543776308825983385
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
HashOneWord(
Jsi_Hash *tablePtr,
const void *key)
{
uint64_t a0, a1;
uint64_t y0, y1;
uint64_t y2, y3;
uint64_t p1, p2;
uint64_t result;
/* Compute key * GOLDEN_RATIO in 128-bit arithmetic */
a0 = (uint64_t)key & 0x00000000FFFFFFFF;
a1 = (uint64_t)key >> 32;
y0 = a0 * 0x000000007f4a7c13;
y1 = a0 * 0x000000009e3779b9;
y2 = a1 * 0x000000007f4a7c13;
y3 = a1 * 0x000000009e3779b9;
y1 += y0 >> 32; /* Can't carry */
y1 += y2; /* Might carry */
if (y1 < y2) {
y3 += (1LL << 32); /* Propagate */
}
/* 128-bit product: p1 = loword, p2 = hiword */
p1 = ((y1 & 0x00000000FFFFFFFF) << 32) + (y0 & 0x00000000FFFFFFFF);
p2 = y3 + (y1 >> 32);
/* Left shift the value downward by the size of the table */
if (tablePtr->downShift > 0) {
if (tablePtr->downShift < 64) {
result = ((p2 << (64 - tablePtr->downShift)) |
(p1 >> (tablePtr->downShift & 63)));
} else {
result = p2 >> (tablePtr->downShift & 63);
}
} else {
result = p1;
}
/* Finally mask off the high bits */
return (jsi_Hash)(result & tablePtr->mask);
}
|
CWE-120
| null | 520,682 |
131719986379850861692130695400579612156
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void mdbStmtLimit( MySqlObj *jdb)
{
while(jdb->numStmts>jdb->maxStmts ) {
Jsi_ListEntry *l = Jsi_ListPopBack(jdb->stmtCache);
mdbRelease1Stmt(jdb, (MysqlPrep*)Jsi_ListValueGet(l));
jdb->numStmts = Jsi_ListSize(jdb->stmtCache);
}
}
|
CWE-120
| null | 520,683 |
304948426520146067050224341928151790724
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_NullToValue(Jsi_Interp *interp, Jsi_OptionSpec* spec, Jsi_Value **outValue, Jsi_DString *outStr, void *record, Jsi_Wide flags)
{
Jsi_ValueMakeNull(interp, outValue);
return JSI_OK;
}
|
CWE-120
| null | 520,684 |
71860677197679934885134065271225921263
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Tree *Jsi_TreeFromValue(Jsi_Interp *interp, Jsi_Value *v)
{
if (!Jsi_ValueIsObjType(interp, v, JSI_OT_OBJECT))
return NULL;
return v->d.obj->tree;
}
|
CWE-120
| null | 520,685 |
203957138031026121156473612168114128245
| null | null |
other
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.