Do not deference value when it does not exist (Thanks D4N)

v0.27.3
Luis Díaz Más 8 years ago
parent 01a5d863ad
commit d21e794239

@ -148,6 +148,11 @@ bool isArray(std::string& value)
template <class T> template <class T>
void push(Jzon::Node& node,const std::string& key,T i) void push(Jzon::Node& node,const std::string& key,T i)
{ {
#define ABORT_IF_I_EMTPY \
if (i->value().size() == 0) { \
return; \
}
std::string value = i->value().toString(); std::string value = i->value().toString();
switch ( i->typeId() ) { switch ( i->typeId() ) {
@ -179,6 +184,7 @@ void push(Jzon::Node& node,const std::string& key,T i)
case Exiv2::unsignedRational: case Exiv2::unsignedRational:
case Exiv2::signedRational: { case Exiv2::signedRational: {
ABORT_IF_I_EMTPY
Jzon::Array arr; Jzon::Array arr;
Exiv2::Rational rat = i->value().toRational(); Exiv2::Rational rat = i->value().toRational();
arr.Add(rat.first ); arr.Add(rat.first );
@ -187,6 +193,7 @@ void push(Jzon::Node& node,const std::string& key,T i)
} break; } break;
case Exiv2::langAlt: { case Exiv2::langAlt: {
ABORT_IF_I_EMTPY
Jzon::Object l ; Jzon::Object l ;
const Exiv2::LangAltValue& langs = dynamic_cast<const Exiv2::LangAltValue&>(i->value()); const Exiv2::LangAltValue& langs = dynamic_cast<const Exiv2::LangAltValue&>(i->value());
for ( Exiv2::LangAltValue::ValueType::const_iterator lang = langs.value_.begin() for ( Exiv2::LangAltValue::ValueType::const_iterator lang = langs.value_.begin()

Loading…
Cancel
Save