Commit 4d8d02a1 authored by Marcus Nordenberg's avatar Marcus Nordenberg

profinet configurator: fix some memory leaks and other memory issues

parent ed36bc73
...@@ -1389,6 +1389,7 @@ pn_gsdml::pn_gsdml() ...@@ -1389,6 +1389,7 @@ pn_gsdml::pn_gsdml()
DeviceFunction(0), ApplicationProcess(0) DeviceFunction(0), ApplicationProcess(0)
{ {
strcpy(gsdmlfile, ""); strcpy(gsdmlfile, "");
set_language("");
} }
pn_gsdml::~pn_gsdml() pn_gsdml::~pn_gsdml()
...@@ -2782,6 +2783,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2782,6 +2783,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced DeviceAccessPointList"); error_message_line("Misplaced DeviceAccessPointList");
delete o;
return 0; return 0;
} }
p->DeviceAccessPointList = o; p->DeviceAccessPointList = o;
...@@ -2802,6 +2804,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2802,6 +2804,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced DeviceAccessPointItem"); error_message_line("Misplaced DeviceAccessPointItem");
delete o;
return 0; return 0;
} }
...@@ -2817,6 +2820,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2817,6 +2820,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ModuleList"); error_message_line("Misplaced ModuleList");
delete o;
return 0; return 0;
} }
p->ModuleList = o; p->ModuleList = o;
...@@ -2835,6 +2839,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2835,6 +2839,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ModuleItem"); error_message_line("Misplaced ModuleItem");
delete o;
return 0; return 0;
} }
...@@ -2860,6 +2865,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2860,6 +2865,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced ModuleInfo"); error_message_line("Misplaced ModuleInfo");
delete o;
return 0; return 0;
} }
...@@ -2878,6 +2884,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2878,6 +2884,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced CertificationInfo"); error_message_line("Misplaced CertificationInfo");
delete o;
return 0; return 0;
} }
...@@ -2896,6 +2903,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2896,6 +2903,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced SubslotList"); error_message_line("Misplaced SubslotList");
delete o;
return 0; return 0;
} }
...@@ -2913,6 +2921,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2913,6 +2921,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced SubslotItem"); error_message_line("Misplaced SubslotItem");
delete o;
return 0; return 0;
} }
p->SubslotItem.push_back(o); p->SubslotItem.push_back(o);
...@@ -2931,6 +2940,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2931,6 +2940,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced IOConfigData"); error_message_line("Misplaced IOConfigData");
delete o;
return 0; return 0;
} }
...@@ -2948,6 +2958,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2948,6 +2958,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced IOConfigData"); error_message_line("Misplaced IOConfigData");
delete o;
return 0; return 0;
} }
...@@ -2966,6 +2977,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2966,6 +2977,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ModuleItemRef"); error_message_line("Misplaced ModuleItemRef");
delete o;
return 0; return 0;
} }
p->ModuleItemRef.push_back(o); p->ModuleItemRef.push_back(o);
...@@ -2984,6 +2996,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -2984,6 +2996,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced VirtualSubmoduleList"); error_message_line("Misplaced VirtualSubmoduleList");
delete o;
return 0; return 0;
} }
...@@ -3000,6 +3013,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3000,6 +3013,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced SubmoduleList"); error_message_line("Misplaced SubmoduleList");
delete o;
return 0; return 0;
} }
...@@ -3018,6 +3032,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3018,6 +3032,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced SystemRedundancy"); error_message_line("Misplaced SystemRedundancy");
delete o;
return 0; return 0;
} }
...@@ -3038,6 +3053,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3038,6 +3053,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced VirtualSubmoduleItem"); error_message_line("Misplaced VirtualSubmoduleItem");
delete o;
return 0; return 0;
} }
...@@ -3056,6 +3072,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3056,6 +3072,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced IOData"); error_message_line("Misplaced IOData");
delete o;
return 0; return 0;
} }
...@@ -3073,6 +3090,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3073,6 +3090,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced Input"); error_message_line("Misplaced Input");
delete o;
return 0; return 0;
} }
...@@ -3090,6 +3108,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3090,6 +3108,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced Output"); error_message_line("Misplaced Output");
delete o;
return 0; return 0;
} }
...@@ -3117,6 +3136,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3117,6 +3136,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced DataItem"); error_message_line("Misplaced DataItem");
delete o;
return 0; return 0;
} }
} }
...@@ -3134,6 +3154,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3134,6 +3154,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced DataItem"); error_message_line("Misplaced DataItem");
delete o;
return 0; return 0;
} }
...@@ -3153,6 +3174,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3153,6 +3174,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced BitDataItem"); error_message_line("Misplaced BitDataItem");
delete o;
return 0; return 0;
} }
...@@ -3172,6 +3194,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3172,6 +3194,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced Const"); error_message_line("Misplaced Const");
delete o;
return 0; return 0;
} }
...@@ -3194,6 +3217,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3194,6 +3217,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced Ref"); error_message_line("Misplaced Ref");
delete o;
return 0; return 0;
} }
...@@ -3212,6 +3236,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3212,6 +3236,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced RecordDataList"); error_message_line("Misplaced RecordDataList");
delete o;
return 0; return 0;
} }
...@@ -3228,6 +3253,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3228,6 +3253,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!parent) if (!parent)
{ {
error_message_line("Misplaced MenuList"); error_message_line("Misplaced MenuList");
delete o;
return 0; return 0;
} }
o->parent_par_record_data_item = parent; o->parent_par_record_data_item = parent;
...@@ -3246,6 +3272,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3246,6 +3272,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!parent) if (!parent)
{ {
error_message_line("Misplaced MenuItem tag"); error_message_line("Misplaced MenuItem tag");
delete o;
return 0; return 0;
} }
...@@ -3264,6 +3291,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3264,6 +3291,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!parent) if (!parent)
{ {
error_message_line("Misplaced MenuRef tag"); error_message_line("Misplaced MenuRef tag");
delete o;
return 0; return 0;
} }
...@@ -3282,6 +3310,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3282,6 +3310,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!parent) if (!parent)
{ {
error_message_line("Misplaced ParameterRef tag"); error_message_line("Misplaced ParameterRef tag");
delete o;
return 0; return 0;
} }
...@@ -3300,6 +3329,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3300,6 +3329,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ParameterRecordItem"); error_message_line("Misplaced ParameterRecordItem");
delete o;
return 0; return 0;
} }
...@@ -3319,6 +3349,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3319,6 +3349,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced F_ParameterRecordItem"); error_message_line("Misplaced F_ParameterRecordItem");
delete o;
return 0; return 0;
} }
...@@ -3340,6 +3371,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3340,6 +3371,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced Graphics"); error_message_line("Misplaced Graphics");
delete o;
return 0; return 0;
} }
...@@ -3356,6 +3388,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3356,6 +3388,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced GraphicItemRef"); error_message_line("Misplaced GraphicItemRef");
delete o;
return 0; return 0;
} }
...@@ -3375,6 +3408,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3375,6 +3408,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced PROFIenergy"); error_message_line("Misplaced PROFIenergy");
delete o;
return 0; return 0;
} }
...@@ -3394,6 +3428,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3394,6 +3428,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced IsochroneMode"); error_message_line("Misplaced IsochroneMode");
delete o;
return 0; return 0;
} }
...@@ -3414,6 +3449,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3414,6 +3449,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced SystemDefinedSubmoduleList"); error_message_line("Misplaced SystemDefinedSubmoduleList");
delete o;
return 0; return 0;
} }
...@@ -3434,6 +3470,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3434,6 +3470,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced InterfaceSubmoduleItem"); error_message_line("Misplaced InterfaceSubmoduleItem");
delete o;
return 0; return 0;
} }
...@@ -3451,6 +3488,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3451,6 +3488,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced General"); error_message_line("Misplaced General");
delete o;
return 0; return 0;
} }
...@@ -3468,6 +3506,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3468,6 +3506,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced DCP_FlashOnceSignalUnit"); error_message_line("Misplaced DCP_FlashOnceSignalUnit");
delete o;
return 0; return 0;
} }
...@@ -3487,6 +3526,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3487,6 +3526,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced RT_Class3Properties"); error_message_line("Misplaced RT_Class3Properties");
delete o;
return 0; return 0;
} }
...@@ -3506,6 +3546,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3506,6 +3546,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced SynchronisationMode"); error_message_line("Misplaced SynchronisationMode");
delete o;
return 0; return 0;
} }
...@@ -3530,6 +3571,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3530,6 +3571,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ApplicationRelations"); error_message_line("Misplaced ApplicationRelations");
delete o;
return 0; return 0;
} }
...@@ -3550,6 +3592,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3550,6 +3592,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ApplicationRelations"); error_message_line("Misplaced ApplicationRelations");
delete o;
return 0; return 0;
} }
...@@ -3570,6 +3613,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3570,6 +3613,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced MediaRedundancy"); error_message_line("Misplaced MediaRedundancy");
delete o;
return 0; return 0;
} }
...@@ -3592,6 +3636,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3592,6 +3636,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced TimingProperties"); error_message_line("Misplaced TimingProperties");
delete o;
return 0; return 0;
} }
...@@ -3605,6 +3650,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3605,6 +3650,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced TimingProperties"); error_message_line("Misplaced TimingProperties");
delete o;
return 0; return 0;
} }
...@@ -3626,6 +3672,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3626,6 +3672,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced RT_Class3TimingProperties"); error_message_line("Misplaced RT_Class3TimingProperties");
delete o;
return 0; return 0;
} }
...@@ -3643,6 +3690,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3643,6 +3690,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced MAUTypeItem"); error_message_line("Misplaced MAUTypeItem");
delete o;
return 0; return 0;
} }
((gsdml_MAUTypeList*)p)->MAUTypeItem.push_back(o); ((gsdml_MAUTypeList*)p)->MAUTypeItem.push_back(o);
...@@ -3658,6 +3706,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3658,6 +3706,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced MAUTypeList"); error_message_line("Misplaced MAUTypeList");
delete o;
return 0; return 0;
} }
((gsdml_PortSubmoduleItem*)p)->MAUTypeList = o; ((gsdml_PortSubmoduleItem*)p)->MAUTypeList = o;
...@@ -3686,6 +3735,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3686,6 +3735,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced PortSubmoduleItem"); error_message_line("Misplaced PortSubmoduleItem");
delete o;
return 0; return 0;
} }
...@@ -3707,6 +3757,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3707,6 +3757,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced UseableSubmodules"); error_message_line("Misplaced UseableSubmodules");
delete o;
return 0; return 0;
} }
...@@ -3724,6 +3775,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3724,6 +3775,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced SubmoduleItemRef"); error_message_line("Misplaced SubmoduleItemRef");
delete o;
return 0; return 0;
} }
...@@ -3741,6 +3793,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3741,6 +3793,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced SlotList"); error_message_line("Misplaced SlotList");
delete o;
return 0; return 0;
} }
...@@ -3758,6 +3811,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3758,6 +3811,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced SlotItem"); error_message_line("Misplaced SlotItem");
delete o;
return 0; return 0;
} }
...@@ -3775,6 +3829,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3775,6 +3829,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced SlotGroups"); error_message_line("Misplaced SlotGroups");
delete o;
return 0; return 0;
} }
...@@ -3793,6 +3848,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3793,6 +3848,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced SlotGroup"); error_message_line("Misplaced SlotGroup");
delete o;
return 0; return 0;
} }
...@@ -3809,6 +3865,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3809,6 +3865,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ValueList"); error_message_line("Misplaced ValueList");
delete o;
return 0; return 0;
} }
...@@ -3827,6 +3884,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3827,6 +3884,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ValueItem"); error_message_line("Misplaced ValueItem");
delete o;
return 0; return 0;
} }
...@@ -3843,6 +3901,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3843,6 +3901,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced Assignments"); error_message_line("Misplaced Assignments");
delete o;
return 0; return 0;
} }
...@@ -3861,6 +3920,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3861,6 +3920,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced Assign"); error_message_line("Misplaced Assign");
delete o;
return 0; return 0;
} }
...@@ -3877,6 +3937,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3877,6 +3937,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ChannelDiagList"); error_message_line("Misplaced ChannelDiagList");
delete o;
return 0; return 0;
} }
...@@ -3895,6 +3956,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3895,6 +3956,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ChannelDiagItem"); error_message_line("Misplaced ChannelDiagItem");
delete o;
return 0; return 0;
} }
...@@ -3911,6 +3973,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3911,6 +3973,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ExtChannelDiagList"); error_message_line("Misplaced ExtChannelDiagList");
delete o;
return 0; return 0;
} }
...@@ -3929,6 +3992,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3929,6 +3992,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ExtChannelDiagItem"); error_message_line("Misplaced ExtChannelDiagItem");
delete o;
return 0; return 0;
} }
...@@ -3945,6 +4009,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3945,6 +4009,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ExtChannelAddValue"); error_message_line("Misplaced ExtChannelAddValue");
delete o;
return 0; return 0;
} }
...@@ -3961,6 +4026,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3961,6 +4026,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced UnitDiagTypeList"); error_message_line("Misplaced UnitDiagTypeList");
delete o;
return 0; return 0;
} }
...@@ -3979,6 +4045,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3979,6 +4045,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced UnitDiagTypeItem"); error_message_line("Misplaced UnitDiagTypeItem");
delete o;
return 0; return 0;
} }
...@@ -3995,6 +4062,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -3995,6 +4062,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced GraphicsList"); error_message_line("Misplaced GraphicsList");
delete o;
return 0; return 0;
} }
...@@ -4013,6 +4081,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -4013,6 +4081,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced GraphicItem"); error_message_line("Misplaced GraphicItem");
delete o;
return 0; return 0;
} }
...@@ -4029,6 +4098,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -4029,6 +4098,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced CategoryList"); error_message_line("Misplaced CategoryList");
delete o;
return 0; return 0;
} }
...@@ -4047,6 +4117,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -4047,6 +4117,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced CategoryItem"); error_message_line("Misplaced CategoryItem");
delete o;
return 0; return 0;
} }
...@@ -4063,6 +4134,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -4063,6 +4134,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced ExternalTextList"); error_message_line("Misplaced ExternalTextList");
delete o;
return 0; return 0;
} }
...@@ -4079,6 +4151,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -4079,6 +4151,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced PrimaryLanguage"); error_message_line("Misplaced PrimaryLanguage");
delete o;
return 0; return 0;
} }
...@@ -4097,6 +4170,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -4097,6 +4170,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
if (!p) if (!p)
{ {
error_message_line("Misplaced Language"); error_message_line("Misplaced Language");
delete o;
return 0; return 0;
} }
...@@ -4118,6 +4192,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id) ...@@ -4118,6 +4192,7 @@ void* pn_gsdml::object_factory(gsdml_eTag id)
else else
{ {
error_message_line("Misplaced Text"); error_message_line("Misplaced Text");
delete o;
return 0; return 0;
} }
...@@ -6388,6 +6463,8 @@ gsdml_SystemDefinedSubmoduleList::~gsdml_SystemDefinedSubmoduleList() ...@@ -6388,6 +6463,8 @@ gsdml_SystemDefinedSubmoduleList::~gsdml_SystemDefinedSubmoduleList()
{ {
for (unsigned int i = 0; i < PortSubmoduleItem.size(); i++) for (unsigned int i = 0; i < PortSubmoduleItem.size(); i++)
delete PortSubmoduleItem[i]; delete PortSubmoduleItem[i];
if (InterfaceSubmoduleItem)
delete InterfaceSubmoduleItem;
} }
gsdml_DeviceAccessPointItem_ApplicationRelations:: gsdml_DeviceAccessPointItem_ApplicationRelations::
...@@ -6431,7 +6508,7 @@ gsdml_SlotGroups::~gsdml_SlotGroups() ...@@ -6431,7 +6508,7 @@ gsdml_SlotGroups::~gsdml_SlotGroups()
} }
gsdml_DeviceAccessPointItem::gsdml_DeviceAccessPointItem(pn_gsdml* g) gsdml_DeviceAccessPointItem::gsdml_DeviceAccessPointItem(pn_gsdml* g)
: ModuleInfo(0), SubslotList(0), IOConfigData(0), UseableModules(0), : ModuleInfo(0), CertificationInfo(0), SubslotList(0), IOConfigData(0), UseableModules(0),
VirtualSubmoduleList(0), SystemDefinedSubmoduleList(0), Graphics(0), VirtualSubmoduleList(0), SystemDefinedSubmoduleList(0), Graphics(0),
ApplicationRelations(0), UseableSubmodules(0), SlotList(0), SlotGroups(0), ApplicationRelations(0), UseableSubmodules(0), SlotList(0), SlotGroups(0),
SystemRedundancy(0), gsdml(g) SystemRedundancy(0), gsdml(g)
...@@ -6464,6 +6541,8 @@ gsdml_DeviceAccessPointItem::~gsdml_DeviceAccessPointItem() ...@@ -6464,6 +6541,8 @@ gsdml_DeviceAccessPointItem::~gsdml_DeviceAccessPointItem()
{ {
if (ModuleInfo) if (ModuleInfo)
delete ModuleInfo; delete ModuleInfo;
if (CertificationInfo)
delete CertificationInfo;
if (SubslotList) if (SubslotList)
delete SubslotList; delete SubslotList;
if (IOConfigData) if (IOConfigData)
...@@ -6472,6 +6551,8 @@ gsdml_DeviceAccessPointItem::~gsdml_DeviceAccessPointItem() ...@@ -6472,6 +6551,8 @@ gsdml_DeviceAccessPointItem::~gsdml_DeviceAccessPointItem()
delete UseableModules; delete UseableModules;
if (VirtualSubmoduleList) if (VirtualSubmoduleList)
delete VirtualSubmoduleList; delete VirtualSubmoduleList;
if (SystemDefinedSubmoduleList)
delete SystemDefinedSubmoduleList;
if (Graphics) if (Graphics)
delete Graphics; delete Graphics;
if (ApplicationRelations) if (ApplicationRelations)
...@@ -6485,6 +6566,7 @@ gsdml_DeviceAccessPointItem::~gsdml_DeviceAccessPointItem() ...@@ -6485,6 +6566,7 @@ gsdml_DeviceAccessPointItem::~gsdml_DeviceAccessPointItem()
delete Body.PhysicalSlots.list; delete Body.PhysicalSlots.list;
if (SystemRedundancy) if (SystemRedundancy)
delete SystemRedundancy; delete SystemRedundancy;
} }
void gsdml_DeviceAccessPointList::build() void gsdml_DeviceAccessPointList::build()
...@@ -6755,6 +6837,8 @@ gsdml_ApplicationProcess::~gsdml_ApplicationProcess() ...@@ -6755,6 +6837,8 @@ gsdml_ApplicationProcess::~gsdml_ApplicationProcess()
{ {
if (DeviceAccessPointList) if (DeviceAccessPointList)
delete DeviceAccessPointList; delete DeviceAccessPointList;
if (ModuleList)
delete ModuleList;
if (SubmoduleList) if (SubmoduleList)
delete SubmoduleList; delete SubmoduleList;
if (ValueList) if (ValueList)
......
...@@ -282,7 +282,10 @@ void GsdmlAttr::activate_cmd_ca() ...@@ -282,7 +282,10 @@ void GsdmlAttr::activate_cmd_ca()
} }
} }
GsdmlAttr::~GsdmlAttr() {} GsdmlAttr::~GsdmlAttr() {
if (wow)
delete wow;
}
GsdmlAttr::GsdmlAttr(void* a_parent_ctx, void* a_object, pn_gsdml* a_gsdml, GsdmlAttr::GsdmlAttr(void* a_parent_ctx, void* a_object, pn_gsdml* a_gsdml,
int a_edit_mode, const char* a_data_filename) int a_edit_mode, const char* a_data_filename)
......
...@@ -1471,13 +1471,21 @@ int GsdmlAttrNav::save(const char* filename) ...@@ -1471,13 +1471,21 @@ int GsdmlAttrNav::save(const char* filename)
(char*)gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i] (char*)gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]
->Body.Name.p, ->Body.Name.p,
sizeof(cd->name)); sizeof(cd->name));
//Make sure we null terminate these in case our buffer is too small to accomodate the entire diag name string.
cd->name[sizeof(cd->name) - 1] = '\0';
if (gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i] if (gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]
->Body.Help.p) ->Body.Help.p)
strncpy(cd->help, {
(char*)gsdml->ApplicationProcess->ChannelDiagList strncpy(cd->help,
->ChannelDiagItem[i] (char*)gsdml->ApplicationProcess->ChannelDiagList
->Body.Help.p, ->ChannelDiagItem[i]
sizeof(cd->help)); ->Body.Help.p,
sizeof(cd->help));
//Make sure we null terminate these in case our buffer is too small to accomodate the entire help string.
cd->help[sizeof(cd->help) - 1] = '\0';
}
dev_data.channel_diag.push_back(cd); dev_data.channel_diag.push_back(cd);
} }
} }
......
...@@ -62,8 +62,8 @@ GsdmlSlotData* GsdmlDeviceData::paste_slotdata = 0; ...@@ -62,8 +62,8 @@ GsdmlSlotData* GsdmlDeviceData::paste_slotdata = 0;
GsdmlChannelDiag::GsdmlChannelDiag() : error_type(0) GsdmlChannelDiag::GsdmlChannelDiag() : error_type(0)
{ {
strcpy(name, ""); memset(name, 0, sizeof(name));
strcpy(help, ""); memset(help, 0, sizeof(help));
} }
int GsdmlChannelDiag::print(std::ofstream& fp) int GsdmlChannelDiag::print(std::ofstream& fp)
...@@ -89,9 +89,18 @@ GsdmlDataRecord::GsdmlDataRecord(const GsdmlDataRecord& x) ...@@ -89,9 +89,18 @@ GsdmlDataRecord::GsdmlDataRecord(const GsdmlDataRecord& x)
int GsdmlDataRecord::print(std::ofstream& fp, bool reverse_endianess) int GsdmlDataRecord::print(std::ofstream& fp, bool reverse_endianess)
{ {
char str[1024]; char str[1024];
unsigned char* data;
unsigned char* data = // If we have allocated memory for reversed endianess we come from the pn configurator otherwise we use the data as is.
(reverse_endianess ? this->data_reversed_endianess : this->data); // The method SetIoDeviceData for instance reads the raw data and then recreates the pn configuration file.
if (data_reversed_endianess)
{
data = (reverse_endianess ? this->data_reversed_endianess : this->data);
}
else
{
data = this->data;
}
co_xml_parser::data_to_ostring(data, data_length, str, sizeof(str)); co_xml_parser::data_to_ostring(data, data_length, str, sizeof(str));
......
...@@ -63,6 +63,8 @@ public: ...@@ -63,6 +63,8 @@ public:
{ {
if (data) if (data)
free(data); free(data);
if (data_reversed_endianess)
free(data_reversed_endianess);
} }
GsdmlDataRecord(const GsdmlDataRecord& x); GsdmlDataRecord(const GsdmlDataRecord& x);
...@@ -170,7 +172,7 @@ public: ...@@ -170,7 +172,7 @@ public:
GsdmlChannelDiag(); GsdmlChannelDiag();
unsigned short error_type; unsigned short error_type;
char name[200]; char name[200];
char help[256]; char help[4096]; // We need a large buffer for most of the help text in the diagnostics...
int print(std::ofstream& fp); int print(std::ofstream& fp);
}; };
...@@ -208,7 +210,10 @@ public: ...@@ -208,7 +210,10 @@ public:
static GsdmlSlotData* paste_slotdata; static GsdmlSlotData* paste_slotdata;
std::vector<GsdmlChannelDiag*> channel_diag; std::vector<GsdmlChannelDiag*> channel_diag;
~GsdmlDeviceData() { device_reset(); } ~GsdmlDeviceData() {
device_reset();
channel_diag_reset();
}
void device_reset() void device_reset()
{ {
for (unsigned int i = 0; i < slot_data.size(); i++) for (unsigned int i = 0; i < slot_data.size(); i++)
......
...@@ -229,7 +229,10 @@ static pwr_tStatus GetIoDeviceData(pwr_tAttrRef Object, const char* Attr, ...@@ -229,7 +229,10 @@ static pwr_tStatus GetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
GsdmlDeviceData* data = new GsdmlDeviceData(); GsdmlDeviceData* data = new GsdmlDeviceData();
sts = data->read(datafile); sts = data->read(datafile);
if (EVEN(sts)) if (EVEN(sts))
{
delete data;
return sts; return sts;
}
sts = data->get_value(Attr, Buf, BufSize); sts = data->get_value(Attr, Buf, BufSize);
...@@ -250,7 +253,10 @@ static pwr_tStatus SetIoDeviceData(pwr_tAttrRef Object, const char* Attr, ...@@ -250,7 +253,10 @@ static pwr_tStatus SetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
GsdmlDeviceData* data = new GsdmlDeviceData(); GsdmlDeviceData* data = new GsdmlDeviceData();
sts = data->read(datafile); sts = data->read(datafile);
if (EVEN(sts)) if (EVEN(sts))
{
delete data;
return sts; return sts;
}
sts = data->modify_value(Attr, Value); sts = data->modify_value(Attr, Value);
if (ODD(sts)) if (ODD(sts))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment