View Issue Details [ Jump to Notes ] | [ Print ] |
ID | Project | Category | View Status | Date Submitted | Last Update |
0004725 | VTK | (No Category) | public | 2007-03-29 21:38 | 2014-09-09 00:04 |
|
Reporter | Cory Quammen | |
Assigned To | Cory Quammen | |
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | |
Platform | | OS | | OS Version | |
Product Version | | |
Target Version | | Fixed in Version | | |
|
Summary | 0004725: vtkXMLShader.cxx places string terminator in incorrect position when reading shaders from files |
Description | Under Windows with Microsoft Visual C++, vtkXMLShader places the string terminator '\0' in the incorrect place if CRLF line endings are used. Apparently, the ifstream.read() function converts two-byte CRLF line endings into a single-byte line ending. Thus, in the current code, the string terminator is placed beyond the end of the shader code, effectively leaving undefined character values in the shader code which causes the shader compiler to fail. I have attached a path file for a fix to this problem that places the string terminator in the correct position. |
Tags | No tags attached. |
|
Project | |
Type | |
|
Attached Files | vtkXMLShader.cxx.patch [^] (1,008 bytes) 1969-12-31 19:00 [Show Content] [Hide Content]### Eclipse Workspace Patch 1.0
#P VTK
Index: IO/vtkXMLShader.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/IO/vtkXMLShader.cxx,v
retrieving revision 1.7
diff -u -r1.7 vtkXMLShader.cxx
--- IO/vtkXMLShader.cxx 22 Mar 2006 08:25:20 -0000 1.7
+++ IO/vtkXMLShader.cxx 30 Mar 2007 01:33:28 -0000
@@ -165,9 +165,16 @@
// Allocate for the file and the null terminator.
this->Code = new char[length+1];
ifp.read(this->Code, length);
+
+ // See how many characters were actually read. On Windows, CRLF line endings
+ // are read as a single char, so the number of read bytes will be less than
+ // the number of bytes reported in the file size query above.
+ int charsRead = ifp.gcount();
+
ifp.close();
+
// Null terminate the string so GL doesn't get confused.
- this->Code[length] = '\0';
+ this->Code[charsRead] = '\0';
}
//-----------------------------------------------------------------------------
int vtkXMLShader::GetLanguage()
|
|