summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2007-07-20 20:38:05 +0000
committerDon Kjer <don@lindenlab.com>2007-07-20 20:38:05 +0000
commitd373dcc7cbed5fdea72c6b71a5594e4e85549b43 (patch)
tree140e20f48db5dc4d7842f05ef2c24ef9e6fc3238 /indra/newview/llpreviewscript.cpp
parentc78f99b0b3b4b9ac99a69b63315e821d89a89a3b (diff)
svn merge -r 64548:64837 svn+ssh://svn/svn/linden/branches/maintenance into release
* WARNING *: maintenance r64837 is not the last rev to use in the next merge. use r65269
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rw-r--r--indra/newview/llpreviewscript.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 9c9c5a9582..2d4a6d11d9 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -1322,7 +1322,10 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename,
LLString line;
while(!feof(fp))
{
- fgets(buffer, MAX_STRING, fp);
+ if (fgets(buffer, MAX_STRING, fp) == NULL)
+ {
+ buffer[0] = '\0';
+ }
if(feof(fp))
{
break;
@@ -1829,12 +1832,16 @@ void LLLiveLSLEditor::loadScriptText(const char* filename)
{
// read in the whole file
fseek(file, 0L, SEEK_END);
- S32 file_length = ftell(file);
+ long file_length = ftell(file);
fseek(file, 0L, SEEK_SET);
char* buffer = new char[file_length+1];
- fread(buffer, file_length, 1, file);
+ size_t nread = fread(buffer, 1, file_length, file);
+ if (nread < (size_t) file_length)
+ {
+ llwarns << "Short read" << llendl;
+ }
+ buffer[nread] = '\0';
fclose(file);
- buffer[file_length] = 0;
mScriptEd->mEditor->setText(buffer);
mScriptEd->mEditor->makePristine();
delete[] buffer;
@@ -2105,7 +2112,10 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename,
while(!feof(fp))
{
- fgets(buffer, MAX_STRING, fp);
+ if (fgets(buffer, MAX_STRING, fp) == NULL)
+ {
+ buffer[0] = '\0';
+ }
if(feof(fp))
{
break;