util: Fixes memory leak in u_printf_test.cpp

That's Fixes: bdc0a862 ("printf: add some unit tests")

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18024>
This commit is contained in:
Yonggang Luo
2022-08-07 22:33:50 +08:00
committed by Marge Bot
parent 11ab608779
commit a1b7682d10

View File

@@ -38,10 +38,8 @@ private:
}
protected:
u_memstream stream;
char *out_buffer = nullptr;
size_t buffer_size = 0;
FILE *out;
struct format {
std::vector<char> fmt;
@@ -54,13 +52,13 @@ protected:
virtual void SetUp()
{
u_memstream_open(&stream, &out_buffer, &buffer_size);
out = u_memstream_get(&stream);
}
virtual void TearDown()
{
free(out_buffer);
if (out_buffer != NULL) {
free(out_buffer);
}
}
void add_format(const char *string, std::vector<unsigned> arg_sizes)
@@ -103,6 +101,10 @@ protected:
std::string parse()
{
u_memstream stream;
FILE* out;
u_memstream_open(&stream, &out_buffer, &buffer_size);
out = u_memstream_get(&stream);
std::vector<u_printf_info> infos;
for (auto& format : formats) {