Jim Tcl
Check-in [569b3d59ce]
Not logged in

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

Overview
Comment:foreach: Avoid memory leak in case of error

Signed-off-by: Steve Bennett <steveb@workware.net.au>

Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 569b3d59ce04a9a0ddb73c979dc080d59e40888c
User & Date: steveb@workware.net.au 2018-07-08 11:48:04
Context
2018-07-08
12:36
exec: Fix environment for windows

The incorrect environment was used in 8f7471a0f

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 5d6623b385 user: steveb@workware.net.au tags: trunk

11:48
foreach: Avoid memory leak in case of error

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 569b3d59ce user: steveb@workware.net.au tags: trunk

11:48
exec: Better adhere to possible vfork restrictions

Avoid modification of any variables on the parents stack. Avoid use of stdio in the event that execve fails.

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: fc4c80e31e user: steveb@workware.net.au tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to jim.c.

11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
.....
11958
11959
11960
11961
11962
11963
11964

11965
11966
11967
11968
11969
11970
11971
        JimListIterInit(&iters[i], argv[i + 1]);
        if (i % 2 == 0 && JimListIterDone(interp, &iters[i])) {
            result = JIM_ERR;
        }
    }
    if (result != JIM_OK) {
        Jim_SetResultString(interp, "foreach varlist is empty", -1);
        return result;
    }

    if (doMap) {
        resultObj = Jim_NewListObj(interp, NULL, 0);
    }
    else {
        resultObj = interp->emptyObj;
................................................................................
        }
    }
  out:
    result = JIM_OK;
    Jim_SetResult(interp, resultObj);
  err:
    Jim_DecrRefCount(interp, resultObj);

    if (numargs > 2) {
        Jim_Free(iters);
    }
    return result;
}

/* [foreach] */







|







 







>







11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
.....
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
        JimListIterInit(&iters[i], argv[i + 1]);
        if (i % 2 == 0 && JimListIterDone(interp, &iters[i])) {
            result = JIM_ERR;
        }
    }
    if (result != JIM_OK) {
        Jim_SetResultString(interp, "foreach varlist is empty", -1);
        goto empty_varlist;
    }

    if (doMap) {
        resultObj = Jim_NewListObj(interp, NULL, 0);
    }
    else {
        resultObj = interp->emptyObj;
................................................................................
        }
    }
  out:
    result = JIM_OK;
    Jim_SetResult(interp, resultObj);
  err:
    Jim_DecrRefCount(interp, resultObj);
  empty_varlist:
    if (numargs > 2) {
        Jim_Free(iters);
    }
    return result;
}

/* [foreach] */