mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-10 04:20:06 +00:00
Check-in a couple submitted char* string portability bug fixes: correct sizing of buffers and stop overwriting preprocessor token names with themselves.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@25402 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
51cdd90fa8
commit
6494baf371
@ -224,7 +224,7 @@ void ProcessConfigFile()
|
||||
}
|
||||
|
||||
if (config == 0) {
|
||||
config = new char[strlen(DefaultConfig)];
|
||||
config = new char[strlen(DefaultConfig) + 1];
|
||||
strcpy(config, DefaultConfig);
|
||||
}
|
||||
|
||||
@ -862,10 +862,10 @@ char** ReadFileData(const char* fileName)
|
||||
{
|
||||
FILE *in;
|
||||
int errorCode = fopen_s(&in, fileName, "r");
|
||||
char* fdata;
|
||||
char *fdata;
|
||||
int count = 0;
|
||||
const int maxSourceStrings = 5;
|
||||
char** return_data = (char**)malloc(maxSourceStrings+1);
|
||||
char** return_data = (char**)malloc(sizeof(char *) * (maxSourceStrings+1));
|
||||
|
||||
//return_data[MAX_SOURCE_STRINGS]=NULL;
|
||||
if (errorCode) {
|
||||
|
@ -9,5 +9,5 @@
|
||||
// source have to figure out how to create revision.h just to get a build
|
||||
// going. However, if it is not updated, it can be a version behind.
|
||||
|
||||
#define GLSLANG_REVISION "25392"
|
||||
#define GLSLANG_DATE "2014/02/18 14:55:42"
|
||||
#define GLSLANG_REVISION "25400"
|
||||
#define GLSLANG_DATE "2014/02/18 16:37:57"
|
||||
|
@ -381,7 +381,7 @@ protected:
|
||||
int InitScanner(TPpContext* cpp);
|
||||
int ScanFromString(char* s);
|
||||
void missingEndifCheck();
|
||||
int lFloatConst(char* str, int len, int ch, TPpToken* ppToken);
|
||||
int lFloatConst(int len, int ch, TPpToken* ppToken);
|
||||
|
||||
bool inComment;
|
||||
|
||||
|
@ -113,7 +113,7 @@ int TPpContext::InitScanner(TPpContext *cpp)
|
||||
* letter 'e', or a precision ending (e.g., F or LF).
|
||||
*/
|
||||
|
||||
int TPpContext::lFloatConst(char* str, int len, int ch, TPpToken* ppToken)
|
||||
int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
|
||||
{
|
||||
bool HasDecimalOrExponent = false;
|
||||
int declen, exp, ExpSign;
|
||||
@ -124,6 +124,7 @@ int TPpContext::lFloatConst(char* str, int len, int ch, TPpToken* ppToken)
|
||||
exp = 0;
|
||||
|
||||
str_len=len;
|
||||
char* str = ppToken->name;
|
||||
if (ch == '.') {
|
||||
HasDecimalOrExponent = true;
|
||||
str[len++]=ch;
|
||||
@ -220,8 +221,6 @@ int TPpContext::lFloatConst(char* str, int len, int ch, TPpToken* ppToken)
|
||||
|
||||
ppToken->dval = strtod(str, 0);
|
||||
}
|
||||
// Suffix:
|
||||
strcpy(ppToken->name, str);
|
||||
|
||||
if (isDouble)
|
||||
return CPP_DOUBLECONSTANT;
|
||||
@ -385,7 +384,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
||||
} while (ch >= '0' && ch <= '9');
|
||||
}
|
||||
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'E' || ch == 'F' || ch == 'l' || ch == 'L')
|
||||
return pp->lFloatConst(ppToken->name, len, ch, ppToken);
|
||||
return pp->lFloatConst(len, ch, ppToken);
|
||||
|
||||
// wasn't a float, so must be octal...
|
||||
if (nonOctal)
|
||||
@ -424,7 +423,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
||||
ch = pp->getChar();
|
||||
} while (ch >= '0' && ch <= '9');
|
||||
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'E' || ch == 'F' || ch == 'l' || ch == 'L') {
|
||||
return pp->lFloatConst(ppToken->name, len, ch, ppToken);
|
||||
return pp->lFloatConst(len, ch, ppToken);
|
||||
} else {
|
||||
// Finish handling signed and unsigned integers
|
||||
int numericLen = len;
|
||||
@ -600,7 +599,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
||||
ch = pp->getChar();
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
pp->ungetChar();
|
||||
return pp->lFloatConst(ppToken->name, 0, '.', ppToken);
|
||||
return pp->lFloatConst(0, '.', ppToken);
|
||||
} else {
|
||||
pp->ungetChar();
|
||||
return '.';
|
||||
|
Loading…
Reference in New Issue
Block a user