Changeset 21827 for branches/gcc-kmk/src


Ignore:
Timestamp:
Nov 29, 2011, 12:18:51 PM (14 years ago)
Author:
dmik
Message:

Fix crash when reading non-existent ODIN.INI.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gcc-kmk/src/kernel32/profile.cpp

    r21755 r21827  
    219219    PROFILESECTION **next_section;
    220220    PROFILEKEY *key, *prev_key, **next_key;
     221
     222    if (file == NULL)
     223        return NULL;
    221224
    222225    first_section = (PROFILESECTION *)HEAP_xalloc( SystemHeap, 0, sizeof(*section) );
     
    10041007    if ( (p = getenv( "ODIN_INI" )) && (f = fopen( p, "r" )) )
    10051008    {
    1006       PROFILE_OdinProfile = PROFILE_Load( f );
    1007       fclose( f );
    1008       strncpy(PROFILE_OdinIniUsed,p,MAX_PATHNAME_LEN);
    1009       PROFILE_OdinIniUsed[MAX_PATHNAME_LEN-1] = 0;
     1009        PROFILE_OdinProfile = PROFILE_Load( f );
     1010        fclose( f );
     1011        strncpy(PROFILE_OdinIniUsed,p,MAX_PATHNAME_LEN);
     1012        PROFILE_OdinIniUsed[MAX_PATHNAME_LEN-1] = 0;
    10101013    }
    10111014    else
    10121015    {
    1013       #if 0 /* Aug 27 2000 4:26am: Why not use the global kernel32Path
    1014              *                (LoadLibrary may cause harm if used...) */
    1015       HINSTANCE hInstance = LoadLibraryA("KERNEL32.DLL");
    1016       GetModuleFileNameA(hInstance,PROFILE_OdinIniUsed,sizeof(PROFILE_OdinIniUsed));
    1017       FreeLibrary(hInstance);
    1018       strcpy(strrchr(PROFILE_OdinIniUsed,'\\')+1,ODINININAME);
    1019       #else
    1020       strcpy(PROFILE_OdinIniUsed, kernel32Path);
    1021       strcat(PROFILE_OdinIniUsed, ODINININAME);
    1022       #endif
    1023       f = fopen(PROFILE_OdinIniUsed, "r");
    1024       PROFILE_OdinProfile = PROFILE_Load(f);
    1025       fclose(f);
     1016        strcpy(PROFILE_OdinIniUsed, kernel32Path);
     1017        strcat(PROFILE_OdinIniUsed, ODINININAME);
     1018        if ((f = fopen(PROFILE_OdinIniUsed, "r")))
     1019        {
     1020            PROFILE_OdinProfile = PROFILE_Load(f);
     1021            fclose(f);
     1022        }
    10261023    }
    10271024
Note: See TracChangeset for help on using the changeset viewer.