forked from loafle/openapi-generator-original
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
|
||||
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
|
||||
return;
|
||||
}
|
||||
|
@ -47,7 +47,14 @@ void
|
||||
delete o;
|
||||
}{{/isContainer}}
|
||||
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}}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace Swagger {
|
||||
|
||||
void
|
||||
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
|
||||
return;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#ifndef SWG_HELPERS_H
|
||||
#define SWG_HELPERS_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
@ -13,6 +13,7 @@
|
||||
#ifndef ModelFactory_H_
|
||||
#define ModelFactory_H_
|
||||
|
||||
#include "SWGObject.h"
|
||||
|
||||
#include "SWGApiResponse.h"
|
||||
#include "SWGCategory.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef _SWG_OBJECT_H_
|
||||
#define _SWG_OBJECT_H_
|
||||
|
||||
#include <QJsonValue>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace Swagger {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user