CHttpFile::QueryInfo() returns "corrupted" CStrings with invalid lengths. - by ijprest

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 773448 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 12/4/2012 12:15:00 PM
Access Restriction Public


The implementation of the CString form of CHttpFile::QueryInfo() calls HttpQueryInfo to determine how big a buffer to allocate, which is always reported in bytes.  

Since CHttpFile::QueryInfo() neglects to divide by sizeof(TCHAR), it ends up allocating a buffer twice as big as necessary in UNICODE builds.

When CHttpFile::QueryInfo() subsequently calls ReleaseBuffer() on the CString, it again specifies the incorrect size.  As a result, the CString thinks it's bigger than it actually is, and cannot be used normally (e.g., in CString contenation scenarios).
Sign in to post a comment.
Posted by Microsoft on 4/29/2014 at 12:31 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from:
Posted by Microsoft on 12/7/2012 at 12:54 AM
Hi ijprest, thanks for your response, we have received your demo project.
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by ijprest on 12/5/2012 at 9:22 AM
I have attached a demo project (I think).
Posted by Microsoft on 12/4/2012 at 11:02 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting a demo project. Please submit this information to us within 3 business days. We look forward to hearing from you with this information.
Posted by Microsoft on 12/4/2012 at 12:51 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(