Fix bad free order in tlcl_generator.c.

Fix suggested by the OpenSUSE friends:

https://build.opensuse.org/package/view_file?expand=1&file=fix-tlcl-generator.patch&package=vboot&project=devel%3AFactory%3AARM%3AContrib%3AChromebook

for this bug:

http://paste.opensuse.org/86254908

BUG=chromium-os:37707
TEST=emerge-daisy vboot_reference
BRANCH=none

Change-Id: I61c116152fab7b997a84f44da89c93b89659e852
Reviewed-on: https://gerrit.chromium.org/gerrit/40902
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
This commit is contained in:
Luigi Semenzato
2013-01-08 16:23:11 -08:00
committed by ChromeBot
parent e8cfa31d54
commit d6acfd441d

View File

@@ -54,7 +54,7 @@ typedef struct Command {
* added at increasing offsets.
*/
static void AddVisibleField(Command* cmd, const char* name, int offset) {
Field* fld = (Field*) malloc(sizeof(Field));
Field* fld = (Field*) calloc(1, sizeof(Field));
if (cmd->fields != NULL) {
assert(offset > fn->offset);
}
@@ -70,7 +70,7 @@ static void AddVisibleField(Command* cmd, const char* name, int offset) {
*/
static void AddInitializedField(Command* cmd, int offset,
int size, uint32_t value) {
Field* fld = (Field*) malloc(sizeof(Field));
Field* fld = (Field*) calloc(1, sizeof(Field));
fld->next = cmd->fields;
cmd->fields = fld;
fld->name = NULL;
@@ -83,7 +83,7 @@ static void AddInitializedField(Command* cmd, int offset,
/* Create a structure representing a TPM command datagram.
*/
Command* newCommand(TPM_COMMAND_CODE code, int size) {
Command* cmd = (Command*) malloc(sizeof(Command));
Command* cmd = (Command*) calloc(1, sizeof(Command));
cmd->size = size;
AddInitializedField(cmd, 0, sizeof(TPM_TAG), TPM_TAG_RQU_COMMAND);
AddInitializedField(cmd, sizeof(TPM_TAG), sizeof(uint32_t), size);
@@ -523,8 +523,8 @@ static void FreeFields(Field* fld) {
static void FreeCommands(Command* cmd) {
if (cmd != NULL) {
Command* next_command = cmd->next;
free(cmd);
FreeFields(cmd->fields);
free(cmd);
FreeCommands(next_command);
}
}