[opensource-dev] Second Pair of eyes needed!
Tiggs Linden
tiggs at lindenlab.com
Tue Aug 31 14:29:32 PDT 2010
You're shadowing fptr in the last if clause:
if (!fptr)
{
LLFILE* fptr = LLFile::fopen(oldLogFileName(filename),
"r"); /*Flawfinder: ignore*/
LL_INFOS("") << "Old :" << file_name << LL_ENDL;
if (!fptr)
{
LLFILE* fptr =
LLFile::fopen(ndsLogFileName(file_name), "r"); /*Flawfinder:
ignore*/
LL_INFOS("") << "Orginal:" << file_name << LL_ENDL;
if (!fptr) return; //No previous conversation
with this name.
}
}
Change that to:
if (!fptr)
{
fptr = LLFile::fopen(oldLogFileName(filename),
"r");/*Flawfinder: ignore*/
LL_INFOS("") << "Old :" << file_name << LL_ENDL;
if (!fptr)
{
LLFILE* fptr =
LLFile::fopen(ndsLogFileName(file_name), "r"); /*Flawfinder:
ignore*/
LL_INFOS("") << "Orginal:" << file_name << LL_ENDL;
if (!fptr) return; //No previous conversation
with this name.
}
}
On Tue, Aug 31, 2010 at 5:22 PM, WolfPup Lowenhar
<wolfpup67 at earthlink.net> wrote:
>
> Sorry folks as this might get a little long.
> First Code Snip its:
> 1. see http://jira.secondlife.com/browse/VWR-20741 for reference to new
> makeLofFileName in patch
> 2. std::string LLLogChat::oldLogFileName(std::string filename)
> {
> time_t now;
> time_t yesterday = time(&now) - 86400;
> char dbuffer[20]; /* Flawfinder: ignore */
> if (filename == "chat")
> {
> strftime(dbuffer, 20, "-%Y-%m-%d", localtime(&yesterday));
> }
> else
> {
> strftime(dbuffer, 20, "-%Y-%m", localtime(&yesterday));
> }
> filename += dbuffer;
> filename = cleanFileName(filename);
> filename =
> gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename);
> filename += ".txt";
> LL_INFOS("") << "Old :" << filename << LL_ENDL;
> return filename;
> }
> 3. std::string LLLogChat::ndsLogFileName(std::string filename)
> {
> filename = cleanFileName(filename);
> filename =
> gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename);
> filename += ".txt";
> LL_INFOS("") << "Original:" << filename << LL_ENDL;
> return filename;
> }
> 4. modified section of void LLLogChat::loadAllHistory(const std::string&
> file_name, std::list<LLSD>& messages)
> {
> if (file_name.empty())
> {
> llwarns << "Session name is Empty!" << llendl;
> return ;
> }
>
> LLFILE* fptr = LLFile::fopen(makeLogFileName(file_name), "r");
> /*Flawfinder: ignore*/
> LL_INFOS("") << "Current:" << file_name << LL_ENDL;
> if (!fptr)
> {
> LLFILE* fptr = LLFile::fopen(oldLogFileName(filename), "r");
> /*Flawfinder: ignore*/
> LL_INFOS("") << "Old :" << file_name << LL_ENDL;
> if (!fptr)
> {
> LLFILE* fptr =
> LLFile::fopen(ndsLogFileName(file_name), "r"); /*Flawfinder:
> ignore*/
> LL_INFOS("") << "Orginal:" << file_name << LL_ENDL;
> if (!fptr) return; //No previous conversation
> with this name.
> }
> }
>
> LL_INFOS("") << "Reading:" << file_name << LL_ENDL;
> char buffer[LOG_RECALL_SIZE]; /*Flawfinder: ignore*/
> char *bptr;
> S32 len;
> bool firstline = TRUE;
> if (fseek(fptr, (LOG_RECALL_SIZE - 1) * -1 , SEEK_END))
>
> Problem:
> When I get done with locating the right named log file and got to read it I
> am ending up with fptr being null and causing viewer lock up and hard crash.
>
> _______________________________________________
> Policies and (un)subscribe information available here:
> http://wiki.secondlife.com/wiki/OpenSource-Dev
> Please read the policies before posting to keep unmoderated posting privileges
More information about the opensource-dev
mailing list