Exemplo n.º 1
0
void mallocEscapeFreeCustomAlloc2() {
  int *p = malloc(12);
  myfoo(p);
  free(p);
  myalloc2(&p);
  free(p); // no warning
}
Exemplo n.º 2
0
EXPORT_C int bar()

{

    MY_MY amymy(0x1234);

    static MY_TYPE mytype(amymy);

    myfoo();

    return mytype.get();

}
Exemplo n.º 3
0
void vallocEscapeFreeUse() {
  int *p = valloc(12);
  myfoo(p);
  free(p);
  myfoo(p); // expected-warning{{Use of memory after it is freed}}
}
Exemplo n.º 4
0
void mallocFreeUse_params() {
  int *p = malloc(12);
  free(p);
  myfoo(p); //expected-warning{{Use of memory after it is freed}}
}
Exemplo n.º 5
0
void mallocEscapeMalloc() {
  int *p = malloc(12);
  myfoo(p);
  p = malloc(12);
} // expected-warning{{Potential leak of memory pointed to by}}
Exemplo n.º 6
0
void mallocBindFreeUse() {
  int *x = malloc(12);
  int *y = x;
  free(y);
  myfoo(x); // expected-warning{{Use of memory after it is freed}}
}
Exemplo n.º 7
0
void mallocEscapeFreeFree() {
  int *p = malloc(12);
  myfoo(p);
  free(p);
  free(p); // expected-warning{{Attempt to free released memory}}
}
Exemplo n.º 8
0
void mallocEscapeFree() {
  int *p = malloc(12);
  myfoo(p);
  free(p);
}
Exemplo n.º 9
0
void mallocEscapeFoo() {
  int *p = malloc(12);
  myfoo(p);
  return; // no warning
}
Exemplo n.º 10
0
void paramFree(int *p) {
  myfoo(p);
  free(p); // no warning
  myfoo(p); // expected-warning {{Use of memory after it is freed}}
}
Exemplo n.º 11
0
Arquivo: malloc.c Projeto: jsgf/clang
void mallocEscapeMalloc() {
  int *p = malloc(12);
  myfoo(p);
  p = malloc(12);
} // expected-warning{{Memory is never released; potential leak}}
Exemplo n.º 12
0
int foo2() {
	return myfoo();
}
Exemplo n.º 13
0
TInt E32Main()
	{
	test.Title();

	test.Start(_L("Test retrieving 0th ordinal and therefore named symbol export data"));
	
	E32EpocExpSymInfoHdr tmpHdr;
	E32EpocExpSymInfoHdr *readHdr;
	RLibrary library;

	// The values for the header of the dll with a 0th ordinal
	tmpHdr.iSize = 0x1a4;
	tmpHdr.iFlags = 0x0;
	tmpHdr.iSymCount = 0xc;	
	tmpHdr.iSymbolTblOffset = 0x1c;
	tmpHdr.iStringTableSz = 0x134;
	tmpHdr.iStringTableOffset = 0x64;
	tmpHdr.iDllCount = 0x3;	
	tmpHdr.iDepDllZeroOrdTableOffset = 0x198;
	test(library.Load(_L("t_oedll.dll")) == KErrNone);
	test.Next(_L("Attempt to retrieve named symbol data from t_oedll.dll"));
	readHdr = (E32EpocExpSymInfoHdr*)library.Lookup(0);
	test(readHdr!=NULL);
	test.Next(_L("Verify export data of t_oedll.dll at the 0th ordinal is that expected"));
	VerifyHdr(tmpHdr, *readHdr);
	library.Close();

	test.Next(_L("Verify lookup on dll without oe export data returns NULL"));
	test(library.Load(_L("t_dll1.dll")) == KErrNone);
	readHdr = (E32EpocExpSymInfoHdr*)library.Lookup(0);
	test(readHdr == NULL);
	library.Close();

	// The values for the header of the exe of the current process with a 0th ordinal
	tmpHdr.iSize = 0x48;
	tmpHdr.iFlags = 0x0;
	tmpHdr.iSymCount = 0x2;
	tmpHdr.iSymbolTblOffset = 0x1c;
	tmpHdr.iStringTableSz = 0x14;
	tmpHdr.iStringTableOffset = 0x28;
	tmpHdr.iDllCount = 0x3;
	tmpHdr.iDepDllZeroOrdTableOffset = 0x3c;
	test.Next(_L("Attempt to retrieve named symbol data from current process"));
	readHdr = (E32EpocExpSymInfoHdr*)(RProcess::ExeExportData());
	test(readHdr!=NULL);
	test.Next(_L("Verify export data at th 0th ordinal of this exe is that expected"));

//#define PRINT_ZEROTH
#ifdef PRINT_ZEROTH
	test.Printf(_L("iSize=%08x;iFlags=%08x;iSymCount=%08x;iSymbolTblOffset=%08x\n"),readHdr->iSize,readHdr->iFlags,readHdr->iSymCount,readHdr->iSymbolTblOffset);
	test.Printf(_L("iStringTableSz=%08x,iStringTableOffset=%08x,iDllCount=%08x,iDepDllZeroOrdTableOffset=%08x\n"), readHdr->iStringTableSz, readHdr->iStringTableOffset,readHdr->iDllCount,readHdr->iDepDllZeroOrdTableOffset);
#endif
	VerifyHdr(tmpHdr, *readHdr);

	test.Next(_L("Verify static dependency t_oedll1 has been fixed up correctly"));
	test(myfoo()==0x1234);

	// Get the 0th ordinal data from the dependency t_oedll1 and verify it
	readHdr=(E32EpocExpSymInfoHdr *)((TUint32)readHdr+readHdr->iDepDllZeroOrdTableOffset);
	TUint32 readHdrEnd = (TUint32)readHdr + 12;
	// This stdexe only links one stddll so the only non-NULL entry in iDepDllZeroOrdTable
	// should point to 0th ordinal of t_oedll1
	while (*(TUint32*)readHdr == NULL && (TUint32)readHdr < readHdrEnd)
		{
		readHdr=(E32EpocExpSymInfoHdr *)(((TUint32*)readHdr)+1);
		}

#ifdef PRINT_ZEROTH
	test.Printf(_L("iSize=%08x;iFlags=%08x;iSymCount=%08x;iSymbolTblOffset=%08x\n"),(*(E32EpocExpSymInfoHdr**)readHdr)->iSize,(*(E32EpocExpSymInfoHdr**)readHdr)->iFlags,(*(E32EpocExpSymInfoHdr**)readHdr)->iSymCount,(*(E32EpocExpSymInfoHdr**)readHdr)->iSymbolTblOffset);
	test.Printf(_L("iStringTableSz=%08x,iStringTableOffset=%08x,iDllCount=%08x,iDepDllZeroOrdTableOffset=%08x\n"), (*(E32EpocExpSymInfoHdr**)readHdr)->iStringTableSz, (*(E32EpocExpSymInfoHdr**)readHdr)->iStringTableOffset,(*(E32EpocExpSymInfoHdr**)readHdr)->iDllCount,(*(E32EpocExpSymInfoHdr**)readHdr)->iDepDllZeroOrdTableOffset);
#endif

	tmpHdr.iSize = 0x1a4;
	tmpHdr.iFlags = 0x0;
	tmpHdr.iSymCount = 0xc;	
	tmpHdr.iSymbolTblOffset = 0x1c;
	tmpHdr.iStringTableSz = 0x134;
	tmpHdr.iStringTableOffset = 0x64;
	tmpHdr.iDllCount = 0x3;	
	tmpHdr.iDepDllZeroOrdTableOffset = 0x198;
	VerifyHdr(tmpHdr,**(E32EpocExpSymInfoHdr**)readHdr);
	
	test.End();
	return KErrNone;
	}