Free some memory allocations

Change-Id: Ifb6c186e43e1eb068e8075def16924ced04bb23d
This commit is contained in:
Matt Mower
2015-09-26 15:40:03 -05:00
parent e0f1f3b4d1
commit 13a8f0b294
3 changed files with 10 additions and 0 deletions
+1
View File
@@ -1572,6 +1572,7 @@ bool TWPartition::Wipe_Encryption() {
} else {
LOGINFO("Successfully wiped crypto footer.\n");
}
free(buffer);
}
}
}
+3
View File
@@ -182,9 +182,12 @@ static int Run_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache)
close(pipe_fd[0]);
execve(Temp_Binary.c_str(), (char* const*)args, environ);
printf("E:Can't execute '%s': %s\n", Temp_Binary.c_str(), strerror(errno));
free(temp);
_exit(-1);
}
close(pipe_fd[1]);
free(temp);
temp = NULL;
*wipe_cache = 0;
+6
View File
@@ -208,32 +208,38 @@ int TWFunc::Try_Decrypting_File(string fn, string password) {
f = fopen(fn.c_str(), "rb");
if (f == NULL) {
LOGERR("Failed to open '%s' to try decrypt\n", fn.c_str());
oaes_free(&ctx);
return -1;
}
read_len = fread(buffer, sizeof(uint8_t), 4096, f);
if (read_len <= 0) {
LOGERR("Read size during try decrypt failed\n");
fclose(f);
oaes_free(&ctx);
return -1;
}
if (oaes_decrypt(ctx, buffer, read_len, NULL, &out_len) != OAES_RET_SUCCESS) {
LOGERR("Error: Failed to retrieve required buffer size for trying decryption.\n");
fclose(f);
oaes_free(&ctx);
return -1;
}
buffer_out = (uint8_t *) calloc(out_len, sizeof(char));
if (buffer_out == NULL) {
LOGERR("Failed to allocate output buffer for try decrypt.\n");
fclose(f);
oaes_free(&ctx);
return -1;
}
if (oaes_decrypt(ctx, buffer, read_len, buffer_out, &out_len) != OAES_RET_SUCCESS) {
LOGERR("Failed to decrypt file '%s'\n", fn.c_str());
fclose(f);
free(buffer_out);
oaes_free(&ctx);
return 0;
}
fclose(f);
oaes_free(&ctx);
if (out_len < 2) {
LOGINFO("Successfully decrypted '%s' but read length too small.\n", fn.c_str());
free(buffer_out);