aboutsummaryrefslogtreecommitdiffstats
path: root/src/renderer.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-07-04 23:59:06 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-07-05 02:51:46 +0200
commitf416c85366a3e85e7f7576398f55595de51adc52 (patch)
tree8fdb0a91865eaa8a58c84d3e97112601b318b460 /src/renderer.c
parent4c228763c31255ea9bd3cd1bbd93f5cf7ab9f54b (diff)
downloadblogc-f416c85366a3e85e7f7576398f55595de51adc52.tar.gz
blogc-f416c85366a3e85e7f7576398f55595de51adc52.tar.bz2
blogc-f416c85366a3e85e7f7576398f55595de51adc52.zip
renderer: utils: fixed memory bugs found by clang static analyzer
Diffstat (limited to 'src/renderer.c')
-rw-r--r--src/renderer.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/renderer.c b/src/renderer.c
index 351dfb1..c9cc15b 100644
--- a/src/renderer.c
+++ b/src/renderer.c
@@ -111,10 +111,10 @@ blogc_format_variable(const char *name, sb_trie_t *global, sb_trie_t *local,
else
value = blogc_get_variable(var, global, local);
- free(var);
-
- if (value == NULL)
+ if (value == NULL) {
+ free(var);
return NULL;
+ }
char *rv = NULL;
@@ -132,6 +132,8 @@ blogc_format_variable(const char *name, sb_trie_t *global, sb_trie_t *local,
rv = sb_strdup(value);
}
+ free(var);
+
if (len > 0) {
char *tmp = sb_strndup(rv, len);
free(rv);