From ab6114fe81eb08864858dbab96e5d55cadbe8e8b Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Tue, 12 Feb 2013 09:30:10 +0100 Subject: [PATCH] Fix init.problem in setmime MimeAttribute ctor * additional check for empty attribute values introduced; * implemented copy-ctor and assignment operator for MimeAttribute; * added missed initialization of parameters in the "UserArgs" MimeAttribute ctor; * Fixes #9444. --- src/bin/setmime.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/bin/setmime.cpp b/src/bin/setmime.cpp index c5ad68e6dd..c69f6fa747 100644 --- a/src/bin/setmime.cpp +++ b/src/bin/setmime.cpp @@ -222,9 +222,12 @@ struct MimeAttribute MimeAttribute(BMessage& msg, int32 index); MimeAttribute(TUserArgs& args); + MimeAttribute(const MimeAttribute& src); status_t InitCheck() { return fStatus; } + MimeAttribute& operator=(const MimeAttribute& src); + void Dump(); void SyncWith(TUserArgs& args) throw(Error); void StoreInto(BMessage* target); @@ -288,12 +291,43 @@ MimeAttribute::MimeAttribute(BMessage& msg, int32 index) MimeAttribute::MimeAttribute(TUserArgs& args) + : + fStatus(B_NO_INIT), + fType('CSTR'), + fViewable(true), + fEditable(false), + fExtra(false), + fWidth(0), + fAlignment(0) { SyncWith(args); fStatus = B_OK; } +MimeAttribute::MimeAttribute(const MimeAttribute& src) +{ + *this = src; +} + + +MimeAttribute& +MimeAttribute::operator=(const MimeAttribute& src) +{ + fStatus = src.fStatus; + fName = src.fName; + fPublicName = src.fPublicName; + fType = src.fType; + fViewable = src.fViewable; + fEditable = src.fEditable; + fExtra = src.fExtra; + fWidth = src.fWidth; + fAlignment = src.fAlignment; + + return *this; +} + + void MimeAttribute::SyncWith(TUserArgs& args) throw(Error) { @@ -609,7 +643,7 @@ MimeType::_Init(char** argv) throw (Error) throw Error("'%s' allowed only after the '%s' ", name, kAttribute); - if (!*++arg) + if (!*++arg || **arg == '-') throw Error("'%s', argument should be specified", name); TUserArgsI A = fUserAttributes.back().find(key);