FS-8185: [core] Allow xml preprocessor to expand variables where the resulting value is much longer than the original size

This commit is contained in:
Michael Jerris 2015-09-17 22:04:19 -05:00
parent 1b60510130
commit d8e7897f1e
1 changed files with 12 additions and 2 deletions

View File

@ -1254,6 +1254,11 @@ static char *expand_vars(char *buf, char *ebuf, switch_size_t elen, switch_size_
*wp++ = *rp++; *wp++ = *rp++;
} }
if (wp == ep) {
return NULL;
}
*wp++ = '\0'; *wp++ = '\0';
*newlen = strlen(ebuf); *newlen = strlen(ebuf);
@ -1394,11 +1399,16 @@ static int preprocess(const char *cwd, const char *file, FILE *write_fd, int rle
break; break;
} }
eblen = len *2; eblen = len * 2;
ebuf = malloc(eblen); ebuf = malloc(eblen);
memset(ebuf, 0, eblen); memset(ebuf, 0, eblen);
bp = expand_vars(buf, ebuf, eblen, &cur, &err); while (!(bp = expand_vars(buf, ebuf, eblen, &cur, &err))) {
eblen *= 2;
ebuf = realloc(ebuf, eblen);
memset(ebuf, 0, eblen);
}
line++; line++;
if (err) { if (err) {