Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Unified Diff: src/trusted/validator/ncfileutil.c

Issue 7799013: Intial Thumb2 Sandbox (naclrev 6680) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: asdsa Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/trusted/validator/ncfileutil.c
diff --git a/src/trusted/validator/ncfileutil.c b/src/trusted/validator/ncfileutil.c
index bb7e6279fe31ab0e95d20dd704176651c1394afb..122e11bcd19e089a656142d0cd3aa66d92d7c131 100644
--- a/src/trusted/validator/ncfileutil.c
+++ b/src/trusted/validator/ncfileutil.c
@@ -186,6 +186,15 @@ static int nc_load(ncfile *ncf, int fd) {
return -1;
}
+ /* Keep a copy of the header around for the validator */
+ ncf->eheader = calloc(1, sizeof(Elf_Ehdr));
+ if (ncf->eheader == NULL) {
+ ncf->error_fn("nc_load(%s): calloc(1, sizeof(Elf_Ehdr)) failed\n",
+ ncf->fname);
+ return -1;
+ }
+ *ncf->eheader = h; /* save the copy */
+
/* success! */
return 0;
}
@@ -212,7 +221,7 @@ ncfile *nc_loadfile_depending(const char *filename,
if (nc_load(ncf, fd) < 0) {
close(fd);
- free(ncf);
+ nc_freefile(ncf);
return NULL;
}
close(fd);
@@ -230,7 +239,11 @@ ncfile *nc_loadfile_with_error_fn(const char *filename,
void nc_freefile(ncfile *ncf) {
- if (ncf->data != NULL) free(ncf->data);
+ if (ncf == NULL) return;
+ free(ncf->data);
+ free(ncf->eheader);
+ free(ncf->pheaders);
+ free(ncf->sheaders);
free(ncf);
}

Powered by Google App Engine
This is Rietveld 408576698