> [wgt-backend/src/wgt/step/encryption/step_encrypt_resources.cc:175]: (error) Resource leak: input
> [wgt-backend/src/wgt/step/encryption/step_encrypt_resources.cc:251]: (error) Deallocating a deallocated pointer: output
> [wgt-backend/src/wgt/extension_config_parser.cc:27]: (performance) Variable 'config_xml_' is assigned in constructor body. Consider performing initialization in initialization list.
Change-Id: I4386dd4b5923566cc2e7ce941144496200fe139b
const char kExtensionNameKey[] = "@name";
} // namespace
const char kExtensionNameKey[] = "@name";
} // namespace
-ExtensionConfigParser::ExtensionConfigParser(std::string config_xml) {
- config_xml_ = config_xml;
-}
+ExtensionConfigParser::ExtensionConfigParser(std::string config_xml)
+ : config_xml_(config_xml) {}
std::unique_ptr<parser::DictionaryValue>
ExtensionConfigParser::LoadExtensionConfig(const std::string& config_xml) {
std::unique_ptr<parser::DictionaryValue>
ExtensionConfigParser::LoadExtensionConfig(const std::string& config_xml) {
void WriteBytes(unsigned char* buffer, std::size_t count, FILE* stream) {
// original file is treated as destination!
void WriteBytes(unsigned char* buffer, std::size_t count, FILE* stream) {
// original file is treated as destination!
+ if (count <= 0) {
+ return;
+ }
std::size_t bytes_written = 0;
std::size_t bytes_written = 0;
- std::size_t bytes_to_write = 0;
- bytes_to_write = count - bytes_written;
- bytes_written = std::fwrite(buffer + bytes_written,
- sizeof(unsigned char),
- count - bytes_written,
- stream);
- if ((bytes_written != bytes_to_write)) {
+ std::size_t bytes_appended = std::fwrite(
+ buffer + bytes_written,
+ sizeof(unsigned char),
+ count - bytes_written,
+ stream);
+ if ((bytes_appended == 0)) {
LOG(ERROR) << "Error while writing data";
LOG(ERROR) << "Error while writing data";
- free(buffer);
- fclose(stream);
- } while ((bytes_written != bytes_to_write));
+ bytes_written += bytes_appended;
+ } while ((bytes_written < count));
FILE *output = OpenFile(encFile.string().c_str(), "wb");
if (output == nullptr) {
LOG(ERROR) << "Cannot create encrypted file: " << encFile.string();
FILE *output = OpenFile(encFile.string().c_str(), "wb");
if (output == nullptr) {
LOG(ERROR) << "Cannot create encrypted file: " << encFile.string();