mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Qt5cpp plug memleaks part2 (#7792)
* Small fixes to prevent crash when empty json body is provided. * Fix some more memory Leaks in the model-body - Members not deleted in cleanup() method, for maps/arrays of primitive types. - Avoid undefined behavior when updating class members with data from missing json fields
This commit is contained in:
parent
f00a1ef52c
commit
1947220159
@ -14,7 +14,7 @@ namespace {{this}} {
|
|||||||
|
|
||||||
void
|
void
|
||||||
setValue(void* value, QJsonValue obj, QString type, QString complexType) {
|
setValue(void* value, QJsonValue obj, QString type, QString complexType) {
|
||||||
if(value == nullptr) {
|
if((value == nullptr) || (obj.isUndefined())) {
|
||||||
// can't set value with a null pointer
|
// can't set value with a null pointer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,14 @@ void
|
|||||||
delete o;
|
delete o;
|
||||||
}{{/isContainer}}
|
}{{/isContainer}}
|
||||||
delete {{name}};
|
delete {{name}};
|
||||||
}{{/complexType}}
|
}{{/complexType}}{{^complexType}}{{#isContainer}}
|
||||||
|
if({{name}} != nullptr) { {{#items.isContainer}}
|
||||||
|
auto arr = {{name}};
|
||||||
|
for(auto o: *arr) {
|
||||||
|
delete o;
|
||||||
|
}{{/items.isContainer}}
|
||||||
|
delete {{name}};
|
||||||
|
}{{/isContainer}}{{/complexType}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace Swagger {
|
|||||||
|
|
||||||
void
|
void
|
||||||
setValue(void* value, QJsonValue obj, QString type, QString complexType) {
|
setValue(void* value, QJsonValue obj, QString type, QString complexType) {
|
||||||
if(value == nullptr) {
|
if((value == nullptr) || (obj.isUndefined())) {
|
||||||
// can't set value with a null pointer
|
// can't set value with a null pointer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#ifndef SWG_HELPERS_H
|
#ifndef SWG_HELPERS_H
|
||||||
#define SWG_HELPERS_H
|
#define SWG_HELPERS_H
|
||||||
|
|
||||||
|
#include <QJsonObject>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#ifndef ModelFactory_H_
|
#ifndef ModelFactory_H_
|
||||||
#define ModelFactory_H_
|
#define ModelFactory_H_
|
||||||
|
|
||||||
|
#include "SWGObject.h"
|
||||||
|
|
||||||
#include "SWGApiResponse.h"
|
#include "SWGApiResponse.h"
|
||||||
#include "SWGCategory.h"
|
#include "SWGCategory.h"
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#ifndef _SWG_OBJECT_H_
|
#ifndef _SWG_OBJECT_H_
|
||||||
#define _SWG_OBJECT_H_
|
#define _SWG_OBJECT_H_
|
||||||
|
|
||||||
#include <QJsonValue>
|
#include <QJsonObject>
|
||||||
|
|
||||||
namespace Swagger {
|
namespace Swagger {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user