cleaned up code

This commit is contained in:
Andrei Medar 2020-08-13 14:59:30 +00:00
parent 28d671efd7
commit acbfec0cb5
4 changed files with 6 additions and 7 deletions

View File

@ -10,5 +10,5 @@ TODO
- clear redundant includes
- check if security policy can be stricter
- ~~use addDirectoryAt instead of addDirectory~~
- modify tests assertions
- ~~modify tests assertions~~

View File

@ -47,7 +47,8 @@ void generate_one_step(SapiLodepngSandbox &sandbox, LodepngApi &api) {
}
// encode the image
sapi::v::Array<unsigned char> sapi_image(image.data(), img_len(width, height));
sapi::v::Array<unsigned char> sapi_image(image.data(),
img_len(width, height));
sapi::v::UInt sapi_width(width), sapi_height(height);
std::string filename = "/output/out_generated1.png";
sapi::v::ConstCStr sapi_filename(filename.c_str());
@ -116,7 +117,8 @@ void generate_two_steps(SapiLodepngSandbox &sandbox, LodepngApi &api) {
}
// encode the image into memory first
sapi::v::Array<unsigned char> sapi_image(image.data(), img_len(width, height));
sapi::v::Array<unsigned char> sapi_image(image.data(),
img_len(width, height));
sapi::v::UInt sapi_width(width), sapi_height(height);
std::string filename = "/output/out_generated2.png";
sapi::v::ConstCStr sapi_filename(filename.c_str());
@ -135,7 +137,6 @@ void generate_two_steps(SapiLodepngSandbox &sandbox, LodepngApi &api) {
// the new array (pointed to by sapi_png_ptr) is allocated
// inside the sandboxed process so we need to transfer it to this
// process
sapi::v::RemotePtr sapi_remote_out_ptr(sapi_png_ptr.GetValue());
sapi::v::Array<unsigned char> sapi_png_array(sapi_pngsize.GetValue());

View File

@ -75,9 +75,9 @@ TEST(generate_image, encode_decode_compare_one_step) {
sapi_height.GetValue()));
ASSERT_THAT(result, Eq(0));
// after the image has been encoded, decode it to check that the
// pixel values are the same
sapi::v::UInt sapi_width2, sapi_height2;
sapi::v::IntBase<unsigned char *> sapi_image_ptr(0);
@ -161,7 +161,6 @@ TEST(generate_image, encode_decode_compare_two_steps) {
// the new array (pointed to by sapi_png_ptr) is allocated
// inside the sandboxed process so we need to transfer it to this
// process
sapi::v::RemotePtr sapi_remote_out_ptr(sapi_png_ptr.GetValue());
sapi::v::Array<unsigned char> sapi_png_array(sapi_pngsize.GetValue());

View File

@ -28,7 +28,6 @@ class SapiLodepngSandbox : public LodepngSandbox {
std::unique_ptr<sandbox2::Policy> ModifyPolicy(
sandbox2::PolicyBuilder *) override {
return sandbox2::PolicyBuilder()
.AllowStaticStartup()
.AllowRead()
.AllowWrite()
.AllowOpen()