@@ -94,12 +94,14 @@ bool Jsonnet::evaluateFile(const std::string& filename, std::string* output)
94
94
return false ;
95
95
}
96
96
int error = 0 ;
97
- const char * jsonnet_output = ::jsonnet_evaluate_file (vm_, filename.c_str (), &error);
97
+ char * jsonnet_output = ::jsonnet_evaluate_file (vm_, filename.c_str (), &error);
98
98
if (error != 0 ) {
99
99
last_error_.assign (jsonnet_output);
100
+ jsonnet_realloc (vm_, jsonnet_output, 0 );
100
101
return false ;
101
102
}
102
103
output->assign (jsonnet_output);
104
+ jsonnet_realloc (vm_, jsonnet_output, 0 );
103
105
return true ;
104
106
}
105
107
@@ -110,13 +112,15 @@ bool Jsonnet::evaluateSnippet(const std::string& filename, const std::string& sn
110
112
return false ;
111
113
}
112
114
int error = 0 ;
113
- const char * jsonnet_output =
115
+ char * jsonnet_output =
114
116
::jsonnet_evaluate_snippet (vm_, filename.c_str(), snippet.c_str(), &error);
115
117
if (error != 0 ) {
116
118
last_error_.assign (jsonnet_output);
119
+ jsonnet_realloc (vm_, jsonnet_output, 0 );
117
120
return false ;
118
121
}
119
122
output->assign (jsonnet_output);
123
+ jsonnet_realloc (vm_, jsonnet_output, 0 );
120
124
return true ;
121
125
}
122
126
@@ -146,12 +150,14 @@ bool Jsonnet::evaluateFileMulti(const std::string& filename,
146
150
return false ;
147
151
}
148
152
int error = 0 ;
149
- const char * jsonnet_output = ::jsonnet_evaluate_file_multi (vm_, filename.c_str (), &error);
153
+ char * jsonnet_output = ::jsonnet_evaluate_file_multi (vm_, filename.c_str (), &error);
150
154
if (error != 0 ) {
151
155
last_error_.assign (jsonnet_output);
156
+ jsonnet_realloc (vm_, jsonnet_output, 0 );
152
157
return false ;
153
158
}
154
159
parseMultiOutput (jsonnet_output, outputs);
160
+ jsonnet_realloc (vm_, jsonnet_output, 0 );
155
161
return true ;
156
162
}
157
163
@@ -162,13 +168,15 @@ bool Jsonnet::evaluateSnippetMulti(const std::string& filename, const std::strin
162
168
return false ;
163
169
}
164
170
int error = 0 ;
165
- const char * jsonnet_output =
171
+ char * jsonnet_output =
166
172
::jsonnet_evaluate_snippet_multi (vm_, filename.c_str(), snippet.c_str(), &error);
167
173
if (error != 0 ) {
168
174
last_error_.assign (jsonnet_output);
175
+ jsonnet_realloc (vm_, jsonnet_output, 0 );
169
176
return false ;
170
177
}
171
178
parseMultiOutput (jsonnet_output, outputs);
179
+ jsonnet_realloc (vm_, jsonnet_output, 0 );
172
180
return true ;
173
181
}
174
182
0 commit comments