void Killed_Building_Script::Killed(GameObject *obj, GameObject *shooter){
/*********why were those functions decs there? (compile error)***********/
char *lpBuff = new char[256]; //MEMORY LEAK why even use the heap? use the stack instead (char lpBuff[256])
int newamount = 1;
int num = atoi(lpBuff); //USE OF UNINITIALIZED MEMORY (crash?)
num -= newamount;
char buffer[50];
char buildingid[16];
sprintf(buildingid, "%d", Commands->Get_ID(obj)); //use %u for unsigned
sprintf(buffer,"%d",num);
char pName[256];
GetPrivateProfileString("BuilderID", buildingid, "nick", lpBuff, 256, "C:\\westwood\\RenegadeFDS\\Server\\ID1.ini");
char *lpBuff2 = new char[257]; //MEMORY LEAK why even use the heap? use the stack instead (char lpBuff2[256])
char building[257];
GetPrivateProfileString("BuildingID2", buildingid, "N", lpBuff2, 257, "C:\\westwood\\RenegadeFDS\\Server\\ID2.ini");
char *lpBuff3 = new char[258]; //MEMORY LEAK why even use the heap? use the stack instead (char lpBuff3[256])
GetPrivateProfileString(pName, building, "0", lpBuff3, 258, "C:\\westwood\\RenegadeFDS\\Server\\Buildings.ini"); //USE OF UNITIALIZED MEMORY (building)
WritePrivateProfileString(pName, building, buffer, "C:\\westwood\\RenegadeFDS\\Server\\Buildings.ini"); //USE OF UNINITIALIZED MEMORY (building)
}
ScriptRegistrant<Killed_Building_Script> Killed_Building_Script_Registrant("Killed_Building_Script","");
|