Chromium Code Reviews| Index: tools/json_schema_compiler/cc_generator.py |
| diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py |
| index 0cde6cab3193639e7fdc2d5bf7041cfbebf71ac2..b434df550f6d543ec9f57d778d68b299a8de1794 100644 |
| --- a/tools/json_schema_compiler/cc_generator.py |
| +++ b/tools/json_schema_compiler/cc_generator.py |
| @@ -888,8 +888,7 @@ class _Generator(object): |
| dst_var, |
| failure_value)) |
| elif underlying_type.property_type == PropertyType.BINARY: |
| - (c.Append('const base::Value* binary_value = NULL;') |
| - .Sblock('if (!%(src_var)s->IsType(base::Value::Type::BINARY)) {') |
| + (c.Sblock('if (!%(src_var)s->IsType(base::Value::Type::BINARY)) {') |
| .Concat(self._GenerateError( |
| '"\'%%(key)s\': expected binary, got " + ' + |
| self._util_cc_helper.GetValueTypeString('%%(src_var)s', True))) |
| @@ -898,19 +897,12 @@ class _Generator(object): |
| c.Append('return %(failure_value)s;') |
| (c.Eblock('}') |
| .Sblock('else {') |
| - .Append(' binary_value =') |
| - .Append(' static_cast<const base::Value*>(%(src_var)s);') |
| ) |
| if is_ptr: |
| - (c.Append('%(dst_var)s.reset(new std::vector<char>(') |
| - .Append(' binary_value->GetBuffer(),') |
| - .Append(' binary_value->GetBuffer() + binary_value->GetSize()));') |
| - ) |
| + c.Append( |
| + '%(dst_var)s.reset(new std::vector<char>(%(src_var)s->GetBlob()));') |
|
jdoerrie
2017/04/25 08:50:34
dst_var might be null, which caused the SIGSEGV on
|
| else: |
| - (c.Append('%(dst_var)s.assign(') |
| - .Append(' binary_value->GetBuffer(),') |
| - .Append(' binary_value->GetBuffer() + binary_value->GetSize());') |
| - ) |
| + c.Append('%(dst_var)s = %(src_var)s->GetBlob();') |
| c.Eblock('}') |
| else: |
| raise NotImplementedError(type_) |