summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuigi Semenzato <semenzato@chromium.org>2013-01-08 16:23:11 -0800
committerChromeBot <chrome-bot@google.com>2013-01-10 11:38:47 -0800
commitd6acfd441d70c0083276a9eed0d89f06bce1d4e6 (patch)
tree240741b007d37b042fa8818877c8444051f6ad8d
parente8cfa31d548c069d73c304fea522b527fe7c7dd6 (diff)
downloadvboot-factory-3536.B.tar.gz
Fix bad free order in tlcl_generator.c.factory-3536.B
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>
-rw-r--r--utility/tlcl_generator.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/utility/tlcl_generator.c b/utility/tlcl_generator.c
index 659a05d6..882562b0 100644
--- a/utility/tlcl_generator.c
+++ b/utility/tlcl_generator.c
@@ -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);
}
}