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

Unified Diff: courgette/patcher_x86_32.h

Issue 1629703002: [Courgette] Refactor: Manage AssemblyProgram and EncodedProgram with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix courgette_fuzzer in libfuzzer. Created 4 years, 11 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 | « courgette/patch_generator_x86_32.h ('k') | courgette/program_detector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/patcher_x86_32.h
diff --git a/courgette/patcher_x86_32.h b/courgette/patcher_x86_32.h
index 28db0596159b886be2e4d82deba9947a667320cc..a80ccc3daa95cd8e71fa11757d4f86e22d43a949 100644
--- a/courgette/patcher_x86_32.h
+++ b/courgette/patcher_x86_32.h
@@ -8,7 +8,11 @@
#include <stdint.h>
#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "courgette/assembly_program.h"
+#include "courgette/encoded_program.h"
#include "courgette/ensemble.h"
+#include "courgette/program_detector.h"
namespace courgette {
@@ -48,39 +52,32 @@ class PatcherX86_32 : public TransformationPatcher {
if (!corrected_parameters->Empty())
return C_GENERAL_ERROR; // Don't expect any corrected parameters.
- AssemblyProgram* program = NULL;
+ scoped_ptr<AssemblyProgram> program;
status = ParseDetectedExecutable(ensemble_region_.start() + base_offset_,
base_length_,
&program);
if (status != C_OK)
return status;
- EncodedProgram* encoded = NULL;
- status = Encode(program, &encoded);
- DeleteAssemblyProgram(program);
+ scoped_ptr<EncodedProgram> encoded;
+ status = Encode(*program, &encoded);
if (status != C_OK)
return status;
- status = WriteEncodedProgram(encoded, transformed_element);
- DeleteEncodedProgram(encoded);
+ program.reset();
- return status;
+ return WriteEncodedProgram(encoded.get(), transformed_element);
}
Status Reform(SourceStreamSet* transformed_element,
SinkStream* reformed_element) {
Status status;
- EncodedProgram* encoded_program = NULL;
+ scoped_ptr<EncodedProgram> encoded_program;
status = ReadEncodedProgram(transformed_element, &encoded_program);
if (status != C_OK)
return status;
- status = Assemble(encoded_program, reformed_element);
- DeleteEncodedProgram(encoded_program);
- if (status != C_OK)
- return status;
-
- return C_OK;
+ return Assemble(encoded_program.get(), reformed_element);
}
private:
@@ -93,4 +90,5 @@ class PatcherX86_32 : public TransformationPatcher {
};
} // namespace
+
#endif // COURGETTE_WIN32_X86_PATCHER_H_
« no previous file with comments | « courgette/patch_generator_x86_32.h ('k') | courgette/program_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698