Changeset 639

Show
Ignore:
Timestamp:
11/02/06 18:20:46 (2 years ago)
Author:
leo
Message:

Fixed potential crash.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/win/Leocad.cpp

    r559 r639  
    6868    { 
    6969        if(HttpQueryInfo(hHttpFile,HTTP_QUERY_CONTENT_LENGTH, szSizeBuffer, &dwLengthSizeBuffer, NULL)) 
    70         {     
     70        { 
    7171            dwFileSize = atol(szSizeBuffer); 
    72             LPSTR szContents = Contents.GetBuffer(dwFileSize); 
    73              
     72            LPSTR szContents = Contents.GetBuffer(dwFileSize+1); 
     73            szContents[dwFileSize] = 0; 
     74 
    7475            if (InternetReadFile(hHttpFile, szContents, dwFileSize, &dwBytesRead)) 
    7576            { 
     
    7778                int lib; 
    7879 
    79                 if (sscanf (szContents, "%f %d", &ver, &lib) == 2) 
     80                if (sscanf(szContents, "%f %d", &ver, &lib) == 2) 
    8081                { 
    8182                    CString str; 
     
    178179 
    179180    char app[LC_MAXPATH], *ptr; 
    180     GetModuleFileName (NULL, app, LC_MAXPATH); 
     181    GetModuleFileName(NULL, app, LC_MAXPATH); 
    181182    ptr = strrchr(app,'\\'); 
    182183    if (ptr) 
     
    227228    { 
    228229        char out[_MAX_PATH]; 
    229         GetTempPath (_MAX_PATH, out); 
    230         strcat (out, "~LC*.lcd"); 
     230        GetTempPath(_MAX_PATH, out); 
     231        strcat(out, "~LC*.lcd"); 
    231232 
    232233        WIN32_FIND_DATA fd; 
     
    234235        if (fh != INVALID_HANDLE_VALUE) 
    235236        { 
    236             if (char *ptr = strrchr (out, '\\')) *(ptr+1) = 0; 
    237             strcat (out, fd.cFileName); 
    238             if (AfxMessageBox (_T("LeoCAD found a file that was being edited while the program exited unexpectdly. Do you want to load it ?"), MB_YESNO) == IDNO) 
     237            if (char *ptr = strrchr(out, '\\')) *(ptr+1) = 0; 
     238            strcat(out, fd.cFileName); 
     239            if (AfxMessageBox(_T("LeoCAD found a file that was being edited while the program exited unexpectdly. Do you want to load it ?"), MB_YESNO) == IDNO) 
    239240            { 
    240                 if (AfxMessageBox (_T("Delete file ?"), MB_YESNO) == IDYES) 
    241                     DeleteFile (out); 
     241                if (AfxMessageBox(_T("Delete file ?"), MB_YESNO) == IDYES) 
     242                    DeleteFile(out); 
    242243            } 
    243244            else 
     
    263264    lcGetActiveProject()->UpdateInterface(); 
    264265 
    265   main_window->UpdateMRU (); 
     266  main_window->UpdateMRU(); 
    266267 
    267268    // Enable drag/drop open