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

Unified Diff: third_party/ijar/ijar.cc

Issue 1901473003: 🐞 Update version of third_party/ijar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « third_party/ijar/common.h ('k') | third_party/ijar/mapped_file.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/ijar/ijar.cc
diff --git a/third_party/ijar/ijar.cc b/third_party/ijar/ijar.cc
index 860b551f662431c460fb4cbd893bae1f077d8d46..1f1c7828790a91951e347958ed6ce31f18835291 100644
--- a/third_party/ijar/ijar.cc
+++ b/third_party/ijar/ijar.cc
@@ -1,6 +1,4 @@
-// Copyright 2001,2007 Alan Donovan. All rights reserved.
-//
-// Author: Alan Donovan <adonovan@google.com>
+// Copyright 2015 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -32,8 +30,8 @@ bool verbose = false;
// Reads a JVM class from classdata_in (of the specified length), and
// writes out a simplified class to classdata_out, advancing the
-// pointer.
-void StripClass(u1 *&classdata_out, const u1 *classdata_in, size_t in_length);
+// pointer. Returns true if the class should be kept.
+bool StripClass(u1*& classdata_out, const u1* classdata_in, size_t in_length);
const char* CLASS_EXTENSION = ".class";
const size_t CLASS_EXTENSION_LENGTH = strlen(CLASS_EXTENSION);
@@ -76,11 +74,17 @@ void JarStripperProcessor::Process(const char* filename, const u4 attr,
if (verbose) {
fprintf(stderr, "INFO: StripClass: %s\n", filename);
}
- u1 *q = builder->NewFile(filename, 0);
- u1 *classdata_out = q;
- StripClass(q, data, size); // actually process it
- size_t out_length = q - classdata_out;
+ u1* buf = reinterpret_cast<u1*>(malloc(size));
+ u1* classdata_out = buf;
+ if (!StripClass(buf, data, size)) {
+ free(classdata_out);
+ return;
+ }
+ u1* q = builder->NewFile(filename, 0);
+ size_t out_length = buf - classdata_out;
+ memcpy(q, classdata_out, out_length);
builder->FinishFile(out_length);
+ free(classdata_out);
}
// Opens "file_in" (a .jar file) for reading, and writes an interface
« no previous file with comments | « third_party/ijar/common.h ('k') | third_party/ijar/mapped_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698