Free Hero Mesh

Check-in [54b97e96bb]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Correct a memory leak in the recent change to the {edit} macro
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 54b97e96bb2d300aec5a9b4894cd65e80b389cc0
User & Date: user on 2023-03-29 23:46:11
Other Links: manifest | tags
Context
2023-03-29
23:50
Implement CONFIG_OMIT_INCLUDE check-in: c3370d4109 user: user tags: trunk
23:46
Correct a memory leak in the recent change to the {edit} macro check-in: 54b97e96bb user: user tags: trunk
19:48
Allow arguments to numeric arithmetic/bitwise macros to be directions and keys as well as numbers. check-in: ee285414da user: user tags: trunk
Changes

Modified class.c from [9cd1ad3346] to [b7fec654af].

1049
1050
1051
1052
1053
1054
1055

1056
1057
1058
1059
1060
1061
1062
1063
1064

1065
1066
1067
1068
1069
1070
1071
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064

1065
1066
1067
1068
1069
1070
1071
1072







+








-
+







          nxttok();
          if(tokent==TF_INT) {
            if(!macstack) ParseError("Empty macro stack\n");
            n=tokenv-1;
            nxttok();
            if(n<0 || macstack->n<=n || !macstack->args[n]) ParseError("Cannot edit nonexistent argument %u\n",n+1);
            if(macstack->args[n]->t&(TF_MACRO|TF_EOF)) ParseError("Invalid edit token\n");
            free(macstack->args[n]->str);
            macstack->args[n]->t=tokent;
            macstack->args[n]->v=tokenv;
            macstack->args[n]->str=0;
            if(*tokenstr) {
              macstack->args[n]->str=strdup(tokenstr);
              if(!macstack->args[n]->str) fatal("Allocation failed\n");
            }
          } else {
            if(!(tokent&TF_NAME) || tokenv!=OP_STRING) ParseError("String literal expected\n");
            if(!(tokent&TF_NAME) || tokenv!=OP_STRING) ParseError("Numeric or string literal expected\n");
            n=glohash[look_hash_mac()].id;
            if(n<0xC000 || n>MAX_MACRO+0xC000-1 || !macros[n-0xC000]) ParseError("Undefined macro: {%s}\n",tokenstr);
            nxttok();
            n-=0xC000;
            if(macros[n]->t&(TF_MACRO|TF_EOF)) ParseError("Invalid edit token\n");
            free(macros[n]->str);
            macros[n]->t=tokent;