Pointer Arguments to memcpy can not be null in UndefinedBehaviorSanitizer.
In this case, both the memory and the size was zero. This change allows
protoc to run under UndefinedBehaviorSanitizer.
* Fix memory leak of exceptions raised by RaiseException()
Currently exceptions raised by RaiseException() is never deallocated because:
* ARC is disabled for this library: https://github.com/google/protobuf/blob/master/BUILD#L913
* It is constructed with `+alloc` but is never `-release`d.
This change fixes the issue by using `-[NSException exceptionWithName:...]` instead, which returns an autoreleased instance, so it is deallocated properly.
* Fix format.
With this fix, Unity using IL2CPP should work with one of two
approaches:
- Call `FileDescriptor.ForceReflectionInitialization<T>` for every
enum present in generated code (including oneof case enums)
- Ensure that IL2CPP uses the same code for int and any int-based
enums
The former approach is likely to be simpler, unless IL2CPP changes
its default behavior. We *could* potentially generate the code
automatically, but that makes me slightly uncomfortable in terms of
generating code that's only relevant in one specific scenario. It
would be reasonably easy to write a tool (separate from protoc) to
generate the code required for any specific set of assemblies, so
that Unity users can include it in their application. We can always
decide to change to generate it automatically later.
The tests can run as what Apple calls a Logic Test (under xctest), which means
it doesn't have to load an full UI App under the simulator, which speeds things
up a fair amount.
The current 15.6.x versions of Visual Studio 2017 contain a bug that
prevent them from compiling the following construct under certain
conditions:
std::unique_ptr<std::unique_ptr<Foo> []> foos;
This will fail to compile if Foo is an abstract class. To work-around
the problem the whole construct was change into:
std::vector<std::unique_ptr<Foo>> foos;
This not only fixes the compiler error but is also more readable than
previous version.
The compiler and util subpackages are created by the build_py class in
setup.py. This has caused an issue in the protobuf package in
conda-forge (https://github.com/conda-forge/protobuf-feedstock/issues/40),
which is fixed by this commit.
The SampleEnumMethod method was previously only called via
reflection, so the Unity linker thought it could be removed. Ditto
the parameterless constructor in ReflectionHelper.
This PR should avoid that issue, reducing the work needed by
customers to use Google.Protobuf from Unity.