Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/bug-1070722 into lp:zorba.
Commit message: Fixing typo in the casting code which leads to a crash (confusion between type and code). Requested reviews: Sorin Marian Nasoi (sorin.marian.nasoi) Related bugs: Bug #1070722 in Zorba: "FOTS: cast tests end in Seg Fault" https://bugs.launchpad.net/zorba/+bug/1070722 For more details, see: https://code.launchpad.net/~zorba-coders/zorba/bug-1070722/+merge/133492 Fixing typo in the casting code which leads to a crash (confusion between type and code). -- https://code.launchpad.net/~zorba-coders/zorba/bug-1070722/+merge/133492 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/types/casting.cpp' --- src/types/casting.cpp 2012-10-08 12:09:36 +0000 +++ src/types/casting.cpp 2012-11-08 14:46:49 +0000 @@ -2206,7 +2206,7 @@ bool GenericCast::castToAtomic( store::Item_t& result, store::Item_t& item, - store::SchemaTypeCode targetType, + store::SchemaTypeCode targetTypeCode, const TypeManager* tm, namespace_context* nsCtx, const QueryLoc& loc) @@ -2214,43 +2214,43 @@ store::ItemFactory* factory = GENV_ITEMFACTORY; zstring sourceString; - store::SchemaTypeCode sourceType = item->getTypeCode(); + store::SchemaTypeCode sourceTypeCode = item->getTypeCode(); - if (sourceType == targetType) + if (sourceTypeCode == targetTypeCode) { result.transfer(item); return true; } - ErrorInfo errorInfo(sourceType, targetType, loc); - - if (targetType == store::XS_NOTATION || - targetType == store::XS_ANY_ATOMIC) - { - RAISE_ERROR(err::XPST0080, loc, ERROR_PARAMS(*errorInfo.theTargetType)); - } - - if (sourceType == store::XS_ANY_ATOMIC) - { - throwTypeException(err::XPTY0004, errorInfo); - } - - if (targetType == store::XS_NCNAME && - sourceType != store::XS_STRING && - sourceType != store::XS_NCNAME && - sourceType != store::XS_UNTYPED_ATOMIC) - { - throwTypeException(err::XPTY0004, errorInfo); - } - - CastFunc castFunc = theCastMatrix[theMapping[sourceType]] - [theMapping[targetType]]; + ErrorInfo errorInfo(sourceTypeCode, targetTypeCode, loc); + + if (targetTypeCode == store::XS_NOTATION || + targetTypeCode == store::XS_ANY_ATOMIC) + { + RAISE_ERROR(err::XPST0080, loc, ERROR_PARAMS(errorInfo.theTargetTypeCode)); + } + + if (sourceTypeCode == store::XS_ANY_ATOMIC) + { + throwTypeException(err::XPTY0004, errorInfo); + } + + if (targetTypeCode == store::XS_NCNAME && + sourceTypeCode != store::XS_STRING && + sourceTypeCode != store::XS_NCNAME && + sourceTypeCode != store::XS_UNTYPED_ATOMIC) + { + throwTypeException(err::XPTY0004, errorInfo); + } + + CastFunc castFunc = theCastMatrix[theMapping[sourceTypeCode]] + [theMapping[targetTypeCode]]; if (castFunc == 0) { throwTypeException(err::XPTY0004, errorInfo); } - if (theMapping[sourceType] == theMapping[store::XS_STRING]) + if (theMapping[sourceTypeCode] == theMapping[store::XS_STRING]) { item->getStringValue2(sourceString); } @@ -2262,15 +2262,15 @@ nsCtx, errorInfo); - DownCastFunc downCastFunc = theDownCastMatrix[theMapping[targetType]]; + DownCastFunc downCastFunc = theDownCastMatrix[theMapping[targetTypeCode]]; if (downCastFunc != 0 && - targetType != store::XS_STRING && - targetType != store::XS_INTEGER) + targetTypeCode != store::XS_STRING && + targetTypeCode != store::XS_INTEGER) { valid = (*downCastFunc)(result, &*result, - targetType, + targetTypeCode, factory, errorInfo); }
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp