Skip to content

Commit ea55027

Browse files
committed
Fix memory leak in LaTeX and HTML output.
1 parent 67e6a4d commit ea55027

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tst_output.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,10 @@ int tst_output_printf(tst_output_stream * output,
229229
msg = malloc (sizeof(char) * 2048);
230230
count = vsnprintf (msg, 2047, format, arglist);
231231
/* Output was truncated */
232-
if (count >= 2047)
232+
if (count >= 2047) {
233+
free(msg);
233234
return -1;
235+
}
234236
tst_output_str_replace ("rank", "<B>rank</B>$", msg, &tmpstrptr);
235237
free (msg);
236238
tst_output_str_replace ("Rank", "<B>Rank</B>", tmpstrptr, &msg);
@@ -250,8 +252,10 @@ int tst_output_printf(tst_output_stream * output,
250252
msg = malloc (sizeof(char) * 2048);
251253
count = vsnprintf (msg, 2047, format, arglist);
252254
/* Output was truncated */
253-
if (count >= 2047)
255+
if (count >= 2047) {
256+
free(msg);
254257
return -1;
258+
}
255259
tst_output_latex_special_chars(msg, &tmpstrptr);
256260
tst_output_str_replace ("<", "$<$", tmpstrptr, &msg);
257261
free (tmpstrptr);

0 commit comments

Comments
 (0)