swagger-api / swagger-api/swagger-codegen

qt5cpp model arguments in DefaultAPI methods should be pointers or passed by reference.

Open
#1,475 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C++ Issue: Bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.