mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
fix Binary_string::c_ptr and c_ptr_safe
if the Ptr="abc", then str_length=3, and for a C ptr it needs Ptr[3]=0; but it passes str_length+1 (=4) to realloc, and realloc allocates arg_length+1 bytes (that is 5) and does Ptr[arg_length]= 0; (Ptr[4]=0)
This commit is contained in:
parent
b9e2002702
commit
4c1ed54bfc
1 changed files with 2 additions and 2 deletions
|
@ -643,7 +643,7 @@ public:
|
|||
Ptr[str_length]=0;
|
||||
return Ptr;
|
||||
}
|
||||
(void) realloc(str_length+1); /* This will add end \0 */
|
||||
(void) realloc(str_length); /* This will add end \0 */
|
||||
return Ptr;
|
||||
}
|
||||
/*
|
||||
|
@ -666,7 +666,7 @@ public:
|
|||
if (Ptr && str_length < Alloced_length)
|
||||
Ptr[str_length]=0;
|
||||
else
|
||||
(void) realloc(str_length + 1);
|
||||
(void) realloc(str_length);
|
||||
return Ptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue