I have a code like shown below
if ((client == NULL) || (client->type == Leave_Agent)) {
but when i changed it with following code i am getting errors in event logs
the modified code is shown below
if (((client == NULL)|| (client->type == Leave_Agent)) && (client->type == 0)) {
errors in event log is
Faulting application name: test.exe, version: 8.0.16.0, time stamp: 0x5036427e
Can any body guide me how to fix this, which stopping my application.The && operator will make any issues in c++ ?
if (((agent == NULL)|| (agent->type == SPUES_ntAgent)) && (agent->type == 0))
If agent is NULL then the left side of && will always be true and agent->type will always be accessed. So a NULL agent ensures a NULL dereference.
You should change your code to ensure it only gets dereferenced if it's not NULL.
I think you wanted to move the () around so that you never dereference the pointer if it's NULL:
if ((agent == NULL)|| ((agent->type == SPUES_ntAgent) && (agent->type == 0))) {
The problem is that you can reach this
agent->type == 0
when agent==NULL.
I cannot comment on how to fix without knowing what behaviour you expect. At the very least you should make sure agent is not dereferenced if it is ==NULL.
Related
I am using Katalon for Android Testing. I want it to click ImageView3 if it is present. If not, it will click ImageView2 (which makes ImageView3 appear later).
I have tried verifyElementVisible and verifyElementNotVisible. Also tried adding the if statement as 'if (Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0) == true)' but this produced the same error.
Mobile.tap(findTestObject('Objects/android.widget.ImageView1'), 0)
if (Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0))
{
Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0)
Mobile.tap(findTestObject('Objects/android.widget.ImageView3'), 0)
Mobile.closeApplication()
} else
{
Mobile.tap(findTestObject('Objects/android.widget.ImageView2'), 30)
Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0)
Mobile.tap(findTestObject('Objects/android.widget.ImageView3'), 0)
Mobile.closeApplication()
}
The error in the log is showing the following:
Reason: com.kms.katalon.core.exception.StepFailedException: Element 'Object Repository/Objects/android.widget.ImageView3' not found at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:48)
As ImageView3 was not found, I would expect it to jump to the else statement. Any suggestion why this is not happening?
The FailureHandling was not set. It would throw an error as this was not set.
Added FailureHandling.OPTIONAL to the if statement
if (Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0, FailureHandling.OPTIONAL))
I have a small C program using libxml2 for parsing xml files. Basicaly, my code is like
xmlDocPtr doc = xmlParseFile("test.xml");
if (doc == nullptr) {
return;
}
xmlNodePtr node = xmlDocGetRootElement(doc);
if (node == nullptr) {
return;
}
...
I'm getting an error situation, where doc != null and node == null. Under which conditions could that happen? I've tested with completely valid, invalid, and empty files, it happens in every case. If file does not exist, doc == null (as it should). I suspect that the program is not able to open the file for some reason, but I've checked rights, and no other program uses that file. Also, this only happens in an environment, where I cannot use a debugger.
I have tried to look up the "identifier not found" error only to find posts where the function must be moved outside the main loop or should use a forward declaration. However, my script is used as a module for a game engine thus has no real main loop and the function in question is called by a different function above the failing line with no issues:
// Create a Steam ID
CSteamID Steam::createSteamID(uint32 steamID, int accountType){
CSteamID cSteamID;
if(accountType < 0 || accountType >= k_EAccountTypeMax){
accountType = 1;
}
cSteamID.Set(steamID, EUniverse(k_EUniversePublic), EAccountType(accountType));
return cSteamID;
}
// Set a Steam user as someone recently played with
void Steam::setPlayedWith(int steamID){
if(SteamFriends() == NULL){
return;
}
CSteamID friendID = createSteamID(steamID);
SteamFriends()->SetPlayedWith(friendID);
}
// Get friend's Steam username
String getFriendPersonaName(int steamID){
if(SteamFriends() == NULL || steamID == 0){
return "";
}
CSteamID friendID = createSteamID(steamID);
bool isDataLoading = SteamFriends()->RequestUserInformation(friendID, true);
if(!isDataLoading){
return SteamFriends()->GetFriendPersonaName(friendID);
}
}
The ID creation function sits at the very top and these two functions come much later. The first one (setPlayedWith) succeeds no problem but the second one (getFriendPersonaName) fails with: 'createSteamID': identifier not found when compiling the script.
I'm kind of at a loss and hopefully someone can point me in the right direction.
if getFriendPersonaName() is a member function then you have forgotten to define it the correct way so it will look like:
string Steam::getFriendPersonaName(int steamID)...
if it is not a member then you can't access it. however you can Only access it if getFriendPersonaName() is a friend function where you should edit the signature to:
String getFriendPersonaName(int steamID, const steam& rhs);
just day before i started to work with aerospike. I have some problem while writing one sample using LDT (Large data types -- Large List). I want to create a key with currdate with appended as key (20160419_2000_List) and later i will add raw data (byte array) as list values.
For that i am able to connect the database correctly, but i am not able to create key for list. Can you please guide me on this.
You can refer the following code to get idea of what i am doing exactly.
m_sTFPKeyStr.assign(datevalue); //datavalue consists datatime string
m_sTFPListStr.assign("List_");
m_sTFPListStr.append(datevalue);
as_key_init_str(&m_sTFPKey, m_sInputNameSpace.c_str(), m_sInputSetName.c_str(), m_sTFPKeyStr.c_str());
if (!as_ldt_init(m_sTFPListKey, m_sTFPListStr.c_str(), AS_LDT_LLIST, NULL))
{
memset(logmessage, 0x0, sizeof(logmessage));
sprintf(logmessage, "CDataBaseManager::SaveTFP Fails to initialize tfplist key %s", m_sTFPListStr.c_str());
m_pCaptureManager->m_pLogMgr->LogMsg(logmessage);
return;
}
Check the length of m_sTFPListStr in your code.
The codes of function as_ldt_init which will check the parameters :
as_ldt * as_ldt_init(as_ldt * ldt, const as_bin_name name, const as_ldt_type type, const as_udf_module_name module)
{
if (!name || name[0] == '\0' || strlen(name) > AS_BIN_NAME_MAX_LEN
|| (module && strlen(module) > AS_UDF_MODULE_MAX_LEN) )
{
return NULL;
}
...
}
As the value of AS_BIN_NAME_MAX_LEN:
#define AS_BIN_NAME_MAX_LEN (AS_BIN_NAME_MAX_SIZE - 1)
#define AS_BIN_NAME_MAX_SIZE 15
function isEmpty(obj) {
return isNone(obj) || (obj.length === 0 && typeof obj !== 'function') || (typeof obj === 'object' && get(obj, 'length') === 0);
}
1) For null and undefined, we have isNone() function
2) For [], '', we have the second check.
3) The purpose of third check?
I believe that is to check for empty objects that have length as an Ember computed property. IE8 and below has no support for Javascript computed properties, so you have to use the Ember syntax to compute them.