[BUG] [cpp-ue4] API often tries to set reference to null when calling GetHttpRetryManager
Created by: leith-bartrich
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Currently, development HEAD generates code that copies a pointer to a reference without doing a null check. The pointer in question is initialized to nullptr and isn't set to anything else until other subsequent code may or may not set it to an instance. There is no documentation to suggest it is somehow illegal to call GetHttpRetryManager before other logic is run.
in cpp, setting a reference to nullptr is undefined behavior. In my case, it generates an access violation when one later tries to read the results of the given getter function.
There are other issues with how the API object is handling the HttpRetryManager. However, this is a simple bug to suggest that there should be a null check, and then probably a UE_LOG of type Fatal should be thrown. So at least, a developer who calls this method before the field is set, gets some feedback rather than undefined cpp behavior occurring later in their own code.
https://docs.unrealengine.com/4.26/en-US/API/Runtime/Core/Logging/ELogVerbosity__Type/
I'll author and submit a pull request shortly.
sidenote: there's what looks to be a bug in SetHttpRetryManager where it's comparing the field to the getter, when probably it means to check the method parameter against the field? It's hard to overlook it when looking at this. But really this bug report and fix will be limited to the undefined behavior of getting the reference.
openapi-generator version
development HEAD
OpenAPI declaration file content or url
any valid API would generate this code.
Generation Details
any valid API would generate this code.
Steps to reproduce
generate any valid api schema