http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1687 *** shadow/1687 Wed May 9 12:13:56 2001 --- shadow/1687.tmp.12602 Wed May 9 12:13:56 2001 *************** *** 0 **** --- 1,90 ---- + +============================================================================+ + | resValue not always updated when making a transcoder | + +----------------------------------------------------------------------------+ + | Bug #: 1687 Product: Xerces-C | + | Status: NEW Version: 1.4 | + | Resolution: Platform: All | + | Severity: Minor OS/Version: All | + | Priority: Low Component: Utilities | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + Bug found in the following function call: + + XMLTranscoder* + XMLTransService::makeNewTranscoderFor( const XMLCh* const encodingName + , XMLTransService::Codes& resValue + , const unsigned int blockSize) + + What is happening is the resValue which should give you the result of the + request (ie unsupportedEncoding, InternalFailure, SupportFilesNotFound, or Ok) + doesn't always get set. These is only one case that I have found where it + actually gets set and that is in the case of an unsupported encoding. (I gave + the function "UTF16" as the encoding name which doesn't actually correspond to + anything right now). + + If I give the function a valid encodingName then resValue never gets modified. + Thus if you depend on the resValue to tell you if the call succeeded or not you + will not always get a valid value back. + + The offending code in the function: + + // If we found it, then call the factory method for it + if (ourMapping) + return ourMapping->makeNew(blockSize); + + // + // For now, we have a little list of encodings that we disallow + // explicitly. So lets check for them up front. They all start with + // IBM, so we can do a quick check to see if we should even do + // anything at all. + // + if (XMLString::startsWith(upBuf, gDisallowPre)) + { + for (unsigned int index = 0; index < gDisallowListSize; index++) + { + // If its one of our guys, then pretend we don't understand it + if (!XMLString::compareString(upBuf, gDisallowList[index])) + return 0; + } + } + + + Just prior to each of the return values there needs to be a statement to set + the resValue to something. One possible solution: + + // If we found it, then call the factory method for it + if (ourMapping){ + XMLTranscoder* temp = ourMapping->makeNew(blockSize); + if(temp == 0) + resValue = XMLTransService::InternalFailure; + else + resValue = XMLTransService::Ok; + return temp; + } + + // + // For now, we have a little list of encodings that we disallow + // explicitly. So lets check for them up front. They all start with + // IBM, so we can do a quick check to see if we should even do + // anything at all. + // + if (XMLString::startsWith(upBuf, gDisallowPre)) + { + for (unsigned int index = 0; index < gDisallowListSize; index++) + { + // If its one of our guys, then pretend we don't understand it + if (!XMLString::compareString(upBuf, gDisallowList[index])) + resValue = XMLTransService::UnsupportedEncoding; + return 0; + } + } + + + By first creating the XMLTranscoder pointer we can test for it's validity. + That way resValue can get a value thats appropriate. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
