fixed file handle leak on read error in 'lib/service/servicedvd.cpp'
Attached Files
Edited by captnoord, 1 August 2014 - 19:44.
Posted 1 August 2014 - 19:53
Fixed while loop scope not being respected in 'lib/gui/elistbox.cpp'
This one is a wierd one, because currently 'something' gets executed.
situation could be compared to:
int number = 10;
while (--number);
{
do_function(number); // is only called once, after the while has completed.
}
The guy who wrote that, could have meant:
int number = 10;
while (--number) // <--- ';' removed.
{
do_function(number); // its called 10x
}
So that's what I did, currently can't test the change as my girl is watching tv
Posted 1 August 2014 - 22:06
fixed file handle leak on read error in 'lib/service/servicedvd.cpp'
The code bcomes a bit more 'ugly' this way.
Such code warantsthe use of goto's, but in this case code could be simplified by using if (fread() && fread() && fread() && fread()) { ...}
I wonder why 'what = nothl(what);' is done twice (already in the original code)
Posted 1 August 2014 - 22:19
Fixed while loop scope not being respected in 'lib/gui/elistbox.cpp'
This one is a wierd one, because currently 'something' gets executed.
situation could be compared to:
int number = 10;
while (--number);
{
do_function(number); // is only called once, after the while has completed.
}
The guy who wrote that, could have meant:
int number = 10;
while (--number) // <--- ';' removed.
{
do_function(number); // its called 10x
}
So that's what I did, currently can't test the change as my girl is watching tv
Good catch captnoord. I introduced this 'bug almost 2 and a half years ago! apparently this border case almost never happens.
I thing the patch is correct!
Posted 1 August 2014 - 22:30
applied the elistbox patch from captnoord.
How did you create the patch? 'git am' refused to apply it because of patch format error. Did you use 'git format-patch'?
(so applied it manually this time.)
Posted 2 August 2014 - 09:15
There is a CFile wrapper that prevents this kind of kludgy code. It's compatible with FILE* but since the destructor cleans up, you don't have to add all those "close" calls.fixed file handle leak on read error in 'lib/service/servicedvd.cpp'
Posted 2 August 2014 - 11:38
There is a CFile wrapper that prevents this kind of kludgy code. It's compatible with FILE* but since the destructor cleans up, you don't have to add all those "close" calls.fixed file handle leak on read error in 'lib/service/servicedvd.cpp'
Thats even better, but if we are doing that we should just search the code for any other use of FILE and replace it with CFile where possible.
Incremental improvement ftw.
Posted 2 August 2014 - 20:43
+1Thats even better, but if we are doing that we should just search the code for any other use of FILE and replace it with CFile where possible.
I have looked into the matter a bit, I personally don't the CFile 'struct' very complete. I'm extending the CFile class
so that it fits the needs of what I have in mind.
Don't worry about patches for now as it is a little more work than I was hoping for.
Posted 3 August 2014 - 14:50
Yeah, you could add read/write methods to it so it looks a bit more OO, so you can write this:I have looked into the matter a bit, I personally don't the CFile 'struct' very complete. I'm extending the CFile class
so that it fits the needs of what I have in mind.
Posted 4 August 2014 - 09:29
CFile f("/tmp/file", "r"); if (!f) return false;I would have preferred:
try { CFile f("/tmp/file", "r"); f.read(buffer, sizeof(buffer)); ... } catch (const std::exception& ex) { report_error_somewhere(ex.what()); }but some things in the E2 code fail to compile when C++ exceptions are enabled.
Edited by MiLo, 4 August 2014 - 09:30.
0 members, 19 guests, 0 anonymous users