~tyhicks/ecryptfs/namelen-test

« back to all changes in this revision

Viewing changes to src/utils/ecryptfs_generate_tpm_key.c

  • Committer: Colin King
  • Date: 2014-01-09 12:33:24 UTC
  • Revision ID: colin.king@canonical.com-20140109123324-dicgo537l8ap88nw
* src/utils/ecryptfs_generate_tpm_key.c
  - free pcrsSelected if realloc fails

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
        int i, c, *pcrsSelected = NULL, numPcrsSelected = 0;
90
90
        TSS_UUID *uuid;
91
91
        BYTE wellknown[] = TSS_WELL_KNOWN_SECRET;
 
92
        char *tmp_pcrs;
92
93
 
93
94
        while (1) {
94
95
                c = getopt(argc, argv, "p:");
97
98
                switch (c) {
98
99
                        case 'p':
99
100
                                numPcrsSelected++;
100
 
                                pcrsSelected = realloc(pcrsSelected,
 
101
                                tmp_pcrs = realloc(pcrsSelected,
101
102
                                                       (sizeof(int) 
102
103
                                                        * numPcrsSelected));
103
 
                                if (pcrsSelected == NULL) {
 
104
                                if (tmp_pcrs == NULL) {
104
105
                                        PRINT_ERR("Malloc of %zd bytes failed.",
105
106
                                                  (sizeof(int)
106
107
                                                   * numPcrsSelected));
 
108
                                        free(pcrsSelected);
107
109
                                        return -1;
108
110
                                }
 
111
                                pcrsSelected = tmp_pcrs;
109
112
                                pcrsSelected[numPcrsSelected - 1] =
110
113
                                        atoi(optarg);
111
114
                                break;