ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > irrXML
forum topic indicator irrXML can read files that don't exist
person icon
Auria
Guest
Quote
2007-10-08 02:24:16

Hi, i use irrXML 1.2 in my code. Function createIrrXMLReader should return 0.

My code looks like this:

     IrrXMLReader* xml = createIrrXMLReader(config.c_str());
     
     if(xml == NULL or xml == 0)
     {
          cerr << "\n\nError : Cannot open config file" << endl;
          exit(0);
     }

but when i run the program, even if the config file doesn't exist, the program still runs. It just has no XML entries.
Am i doing something wrong?

I am on mac OS X 10.4.10 PPC.

person icon
niko
Moderator
Quote
2007-10-08 17:52:39

ah, interesting. That looks like a bug, but at least it won't do anything more evil like crashing. :)

person icon
Auria
Guest
Quote
2007-10-08 20:38:23

[quote=3]ah, interesting. That looks like a bug, but at least it won't do anything more evil like crashing. :)[/quote]

Well in my case it's as bad as crashing because the user will have no clue why it fails if he does a typo when passing the config file name as argument... anyway, do you think you'll have time to look at it?

person icon
Auria
Guest
Quote
2007-10-10 01:15:41

Hi, i took a look at the source and it doesn't seem like there is a check at all


IrrXMLReader* createIrrXMLReader(const char* filename)
{
     return new CXMLReaderImpl<char, IXMLBase>(new CFileReadCallBack(filename));
}


If the file does not exist, CFileReadCallBack::File will be NULL, but CFileReadCallBack will not and CXMLReaderImpl neither. I don't think 'new' ever returns NULL unless there is not enough memory perhaps

This bug can be fixed by making the function:

IrrXMLReader* createIrrXMLReader(const char* filename)
{
     CFileReadCallBack* file = new CFileReadCallBack(filename);
     if(file->getSize() == 0) return NULL;
     return new CXMLReaderImpl<char, IXMLBase>(file);
}

I didn't look at the other simialr ones though.


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |