summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Moore <Robert.Moore@intel.com>2016-11-16 10:40:00 -0800
committerGitHub <noreply@github.com>2016-11-16 10:40:00 -0800
commitfd0b3e1b86a7ba524525b2e04df826d0aa71383d (patch)
treef85dfb715b2c483efe5a6a069857fe02f1dad961
parenta670da6d3d410b035b9177ddb849ee53346b3adc (diff)
parentb0f2f96693b0f2fd95601f1c68cf06f2167ecf6e (diff)
downloadacpica-fd0b3e1b86a7ba524525b2e04df826d0aa71383d.tar.gz
Merge pull request #180 from coypoop/master
avoid resource leak, check for alloc failure
-rw-r--r--source/common/acfileio.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source/common/acfileio.c b/source/common/acfileio.c
index 6cb953633..8af52d117 100644
--- a/source/common/acfileio.c
+++ b/source/common/acfileio.c
@@ -184,7 +184,7 @@ AcGetAllTablesFromFile (
if (FileSize == ACPI_UINT32_MAX)
{
Status = AE_ERROR;
- goto ErrorExit;
+ goto Exit;
}
fprintf (stderr,
@@ -196,7 +196,7 @@ AcGetAllTablesFromFile (
if (FileSize < sizeof (ACPI_TABLE_HEADER))
{
Status = AE_BAD_HEADER;
- goto ErrorExit;
+ goto Exit;
}
/* Check for an non-binary file */
@@ -206,7 +206,8 @@ AcGetAllTablesFromFile (
fprintf (stderr,
" %s: File does not appear to contain a valid AML table\n",
Filename);
- return (AE_TYPE);
+ Status = AE_TYPE;
+ goto Exit;
}
/* Read all tables within the file */
@@ -225,11 +226,12 @@ AcGetAllTablesFromFile (
}
else if (Status == AE_TYPE)
{
- return (AE_OK);
+ Status = AE_OK;
+ goto Exit;
}
else if (ACPI_FAILURE (Status))
{
- goto ErrorExit;
+ goto Exit;
}
/* Print table header for iASL/disassembler only */
@@ -242,6 +244,11 @@ AcGetAllTablesFromFile (
/* Allocate and link a table descriptor */
TableDesc = AcpiOsAllocate (sizeof (ACPI_NEW_TABLE_DESC));
+ if (!TableDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Exit;
+ }
TableDesc->Table = Table;
TableDesc->Next = NULL;
@@ -276,7 +283,7 @@ AcGetAllTablesFromFile (
*ReturnListHead = ListHead;
}
-ErrorExit:
+Exit:
fclose(File);
return (Status);
}