fix recursive macros with environment variables

This commit is contained in:
2023-03-31 17:31:15 +02:00
parent e3696d910f
commit 3b8d4aa71c
+3 -1
View File
@@ -435,6 +435,7 @@ int dbLoadTemplate(const char *sub_file, const char *cmd_collect, const char *pa
const
#endif
char*[]){ "", "environ", NULL, NULL }) != 0) return -1;
macSuppressWarning(macHandle, 1);
#if (0 && EPICSVER<31403)
/* Have no environment macro substitution, thus load envionment explicitly */
@@ -459,7 +460,7 @@ int dbLoadTemplate(const char *sub_file, const char *cmd_collect, const char *pa
printf("runScript: environ %s\n", *pairs);
/* take a copy to replace '=' with null byte */
if ((var = strdup(*pairs)) == NULL) goto error;
if ((var = strdup(*pairs)) == NULL) continue;
eq = strchr(var, '=');
if (eq)
{
@@ -473,6 +474,7 @@ int dbLoadTemplate(const char *sub_file, const char *cmd_collect, const char *pa
vars = malloc(dbTemplateMaxVars * sizeof(char*));
sub_collect = malloc(dbTemplateMaxVars * MAX_VAR_FACTOR);
if (!vars || !sub_collect) {
if (macHandle) macDeleteHandle(macHandle);
free(vars);
free(sub_collect);
fclose(fp);