swagger-api / swagger-api/swagger-codegen
qt5cpp model arguments in DefaultAPI methods should be pointers or passed by reference.
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
The qt5cpp generator creates a method signature like this in SWGDefaultAPI:
void profileRoutePost(SWGProfile_route_body body, QString* token);
In C/CPP, this will cause 'body' to be copied. There is no proper copy constructor created for the models however, so pointers are re-used instead of new members being allocated.
When profileRoutePost returns, it will destroy the new copy of body and free the pointers. When the application eventually frees the original SWGProfile_route_body in the calling code, it will try to free the same pointers again, causing a segmentation fault due to a double free.
Performance wise, it's also really inefficient to be copying these objects unless that's really needed. Either passing by reference or pointer would fix the segfault and the unneeded copy.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the qt5cpp generator template or entry point that emits SWGDefaultAPI and the profileRoutePost signature. Confirm how model arguments are generated, then change the generated signature so the model is not passed by value; done means the generated API avoids the reported copy and double-free behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100