Files
Ivan Maidanski 9d019e2ef4 Fix null pointer dereference in get_private_path_and_zero_file (Symbian)
* extra/symbian.cpp (GC_get_private_path_and_zero_file): Do not call
memcpy() if allocation of copyChar is failed.
* os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON] (zero_fd): Initialize
global variable to -1 (instead of 0).
* os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON && SYMBIAN]
(GC_unix_mmap_get_mem): Do not call open() and free() if path is NULL.
2018-04-06 09:32:12 +03:00

53 lines
987 B
C++

#include <e32cmn.h>
#include <e32std.h>
#include <f32file.h>
#include <aknutils.h>
#include <stdlib.h>
#include <string.h>
extern "C" {
int GC_get_main_symbian_stack_base()
{
TThreadStackInfo aInfo;
TInt err = RThread().StackInfo(aInfo);
if ( !err )
{
return aInfo.iBase;
}
else
{
return 0;
}
}
char* GC_get_private_path_and_zero_file()
{
// always on c: drive
RFs fs;
fs.Connect();
fs.CreatePrivatePath( EDriveC );
TFileName path;
fs.PrivatePath( path );
fs.Close();
_LIT( KCDrive, "c:" );
path.Insert( 0, KCDrive );
//convert to char*, assume ascii
TBuf8<KMaxFileName> path8;
path8.Copy( path );
_LIT8( KZero8, "zero" );
path8.Append( KZero8 );
size_t size = path8.Length() + 1;
char* copyChar = (char*) malloc( size );
if (copyChar)
memcpy( copyChar, path8.PtrZ(), size );
return copyChar; // ownership passed
}
} /* extern "C" */