From da9138fe29ae9e52982d48552e35ef8369d9c1f6 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 15 Dec 2015 00:14:48 +0300 Subject: [PATCH] fix crash in form processing --- spectrum/src/frontends/xmpp/formutils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spectrum/src/frontends/xmpp/formutils.cpp b/spectrum/src/frontends/xmpp/formutils.cpp index 1ccbe63e..913dce48 100644 --- a/spectrum/src/frontends/xmpp/formutils.cpp +++ b/spectrum/src/frontends/xmpp/formutils.cpp @@ -168,7 +168,8 @@ void addTextFixedField(Swift::Form::ref form, const std::string &value) { std::string fieldValue(Swift::FormField::ref field) { #if HAVE_SWIFTEN_3 - return field->getValues()[0]; + const std::vector values = field->getValues(); + return values.empty() ? "" : values[0]; #else TextSingleFormField::ref textSingle = boost::dynamic_pointer_cast(field); if (textSingle) { @@ -199,8 +200,9 @@ std::string fieldValue(Swift::Form::ref form, const std::string &key, const std: for (std::vector::const_iterator it = fields.begin(); it != fields.end(); it++) { #if HAVE_SWIFTEN_3 FormField::ref field = *it; + const std::vector values = field->getValues(); if (field->getName() == key) { - return field->getValues()[0]; + return values.empty() ? "" : values[0]; } #else TextSingleFormField::ref textSingle = boost::dynamic_pointer_cast(*it);