diff options
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rw-r--r-- | indra/newview/llpreviewscript.cpp | 20 |
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; |