Blob
- Date:
- Message:
- template: fix possible use-after-free and drop the `render' sugar if some of the tp_* function fails, the inner code could free the template too (that's what galileo does), so `tp->tp_ret' would access free'd memory! Instead, add a local variable `tp_ret' to keep track of the return code. While here, drop the `render' shortand that adds the argument call, the template_reset function and adapt the regress.
- Actions:
- History | Blame | Raw File
1 {!2 #include <stdlib.h>3 #include <string.h>4 !}6 {{ define base(struct template *tp, const char *title) }}7 {! char *foo = NULL; !}8 <!doctype html>9 <html>10 <head>11 <title>{{ title }}</title>12 </head>13 <body>14 <h1>{{ title }}</h1>15 {{ if strchr(title, '*') != NULL }}16 <p>"{{ title }}" has a '*' in it</p>17 {{ if 1 }}18 <p>tautology!</p>19 {{ end }}20 {{ else if strchr(title, '=') != NULL }}21 <p>"{{ title }}" has a '=' in it!</p>22 {{ else }}23 <p>"{{ title }}" doesn't have a '*' in it</p>24 {{ end }}25 </body>26 </html>27 {{ finally }}28 {! free(foo); !}29 {{ end }}