1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-09 22:24:09 +03:00

fix problem of reallocated string

This commit is contained in:
Oleksandr Byelkin
2025-02-20 00:06:09 +01:00
parent 3deac2ea77
commit 7544fd4cae

View File

@@ -634,6 +634,9 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count,
}
#ifndef DBUG_OFF
static char dbug_row_print_buf[4096];
/*
Print table's current row into a buffer and return a pointer to it.
@@ -649,11 +652,9 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count,
const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names)
{
Field **pfield;
const size_t alloc_size= 512;
char *row_buff= (char *) alloc_root(&table->mem_root, alloc_size);
char *row_buff_tmp= (char *) alloc_root(&table->mem_root, alloc_size);
String tmp(row_buff_tmp, alloc_size, &my_charset_bin);
String output(row_buff, alloc_size, &my_charset_bin);
char row_buff_tmp[512];
String tmp(row_buff_tmp, sizeof(row_buff_tmp), &my_charset_bin);
String output(dbug_row_print_buf, sizeof(dbug_row_print_buf), &my_charset_bin);
auto move_back_lambda= [table, rec]() mutable {
table->move_fields(table->field, table->record[0], rec);
@@ -717,8 +718,10 @@ const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names)
}
}
output.append(")");
return output.c_ptr_safe();
if (output.c_ptr() == dbug_row_print_buf)
return dbug_row_print_buf;
else
return "Couldn't fit into buffer";
}