3 source/interpret.c | 37 ++++++++++++++++++++++++-------------
4 source/interpret.h | 4 ++--
5 2 files changed, 26 insertions(+), 15 deletions(-)
7 diff --quilt old/source/interpret.c new/source/interpret.c
8 --- old/source/interpret.c
9 +++ new/source/interpret.c
10 @@ -860,12 +860,12 @@ Symbol *LookupSymbol(const char *name)
12 Symbol *InstallSymbol(const char *name, enum symTypes type, DataValue value)
16 - s = (Symbol *)malloc(sizeof(Symbol));
17 - s->name = (char *)malloc(strlen(name)+1); /* +1 for '\0' */
18 + /* no +1, because of .name[1] */
19 + s = malloc(sizeof(Symbol) + strlen(name));
20 strcpy(s->name, name);
24 if (type == LOCAL_SYM) {
25 @@ -1223,15 +1223,14 @@ static void restoreContext(RestartData *
26 static void freeSymbolTable(Symbol *symTab)
30 while(symTab != NULL) {
42 #define POP(dataVal) \
45 @@ -2720,18 +2719,30 @@ int OverlayRoutineFromSymbol(Symbol *sym
46 ** executed in the caller's context from a function in macro.c.
49 int OverlayRoutineFromProg(Program *prog, int nArgs, int removeArgs)
55 + /* no +1, because of .name[1] */
56 + sym = malloc(sizeof(Symbol) + strlen(prog->name));
61 + sym->type = MACRO_FUNCTION_SYM;
62 + strcpy(sym->name, prog->name);
63 + sym->value.val.prog = prog;
67 + ret = OverlayRoutineFromSymbol(sym, nArgs, removeArgs);
69 - sym.type = MACRO_FUNCTION_SYM;
70 - sym.name = prog->name;
71 - sym.value.val.str.rep = (char *)prog;
75 - return OverlayRoutineFromSymbol(&sym, nArgs, removeArgs);
80 ** For special call style where the $args array in the called function is
81 ** assigned from an array in the caller (as "calledFunc(=argsArray)"),
82 diff --quilt old/source/interpret.h new/source/interpret.h
83 --- old/source/interpret.h
84 +++ new/source/interpret.h
85 @@ -106,15 +106,15 @@ typedef struct SparseArrayEntryTag {
89 /* symbol table entry */
90 typedef struct SymbolRec {
94 - struct SymbolRec *next; /* to link to another */
96 + struct SymbolRec *next; /* to link to another */
100 typedef struct ProgramTag {
101 Symbol *localSymList;