Add support for zero-length buffer-to-string conversions.

Allow zero length strings during interpreter buffer-to-string
conversions. For example, during the ToDecimalString and ToHexString
operaters, as well as implicit conversions. Fiodor Suietov.
ACPICA BZ 585.
This commit is contained in:
Robert Moore 2008-09-24 14:12:53 -07:00
parent b0a4040faf
commit 1f1bb7db67

View File

@ -638,8 +638,14 @@ AcpiExConvertToString (
/*
* Create a new string object and string buffer
* (-1 because of extra separator included in StringLength from above)
* Allow creation of zero-length strings from zero-length buffers.
*/
ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) (StringLength - 1));
if (StringLength)
{
StringLength--;
}
ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
if (!ReturnDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
@ -663,7 +669,10 @@ AcpiExConvertToString (
* Null terminate the string
* (overwrites final comma/space from above)
*/
NewBuf--;
if (ObjDesc->Buffer.Length)
{
NewBuf--;
}
*NewBuf = 0;
break;