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
@ -643,7 +643,7 @@ public:
|
|||||||
Ptr[str_length]=0;
|
Ptr[str_length]=0;
|
||||||
return Ptr;
|
return Ptr;
|
||||||
}
|
}
|
||||||
(void) realloc(str_length+1); /* This will add end \0 */
|
(void) realloc(str_length); /* This will add end \0 */
|
||||||
return Ptr;
|
return Ptr;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -666,7 +666,7 @@ public:
|
|||||||
if (Ptr && str_length < Alloced_length)
|
if (Ptr && str_length < Alloced_length)
|
||||||
Ptr[str_length]=0;
|
Ptr[str_length]=0;
|
||||||
else
|
else
|
||||||
(void) realloc(str_length + 1);
|
(void) realloc(str_length);
|
||||||
return Ptr;
|
return Ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user