Comments (8)
Ugg, sorry:
f = NULL;
No dereference. my bad.
Original comment by [email protected]
on 20 Aug 2009 at 7:21
from mp4v2.
Whoa. That's wrong in so many ways.
As stated by point #3 you desire MP4FileHandle hFile to be set to NULL after
object is destroyed.
That is not possible as hFile must be MP4FileHandle* in order to accomplish the
enhancement you desire.
In case it was changed, then yes a simple "*hFile = NULL" would be your
enhancement.
Unfortunately this will break all existing MP4Close() usage.
Secondly, it is illegal to assign NULL to an object, which 'f' represents. The
reason why you do not get a
compiler error is because MP4File(int) constructor accepts an integer. In my
opinion it would be best to
change MP4File(int) --> "explicit MP4File(int)" to avoid implicit conversion of
NULL to a new object.
"f = NULL;" does the following which I'm sure is not desired:
1. create a temporary MP4File object by using constructor MP4File(int) which
allows NULL to be used as per
not perfectly clear C++ standard.
2. assign the tmp object to f (this uses default object copy semantics because
there is no custom defined
copy constructor)
3. this behavior would be undefined because 'f' was just deleted. while it
might not generate a coredump,
because the memory is most likely still available, it's certainly undefined to
use a dead object with copy
semantics.
Original comment by [email protected]
on 15 Sep 2009 at 11:45
from mp4v2.
Small correction. It's strictly not "illegal" to assign NULL to an object. You
need help from implicit constructors or
overloaded assignment operators. In either case though, it's not what you
desire to do for this issue.
Original comment by [email protected]
on 15 Sep 2009 at 11:48
from mp4v2.
In my haste, I wrote some bad code. Sorry. Let me explain myself better.
Here is the specific function:
void MP4Close(MP4FileHandle hFile)
{
if( !MP4_IS_VALID_FILE_HANDLE( hFile ))
return;
MP4File& f = *(MP4File*)hFile;
try {
f.Close();
}
catch ( MP4Error* e ) {
PRINT_ERROR( e );
delete e;
}
delete &f;
}
MP4FileHandle is simply a void*:
typedef void* MP4FileHandle;
...that is, just a pointer. So the fix should be:
void MP4Close(MP4FileHandle hFile)
{
...
delete &f;
hFile = NULL;
}
In general, when you delete something a pointer points to (and in this case,
hFile
points to MP4File*), you should also set it to null. Other places in the
library do
this consistently, so I don't know why this function wouldn't.
Original comment by [email protected]
on 16 Sep 2009 at 12:00
from mp4v2.
Also,
"*hFile = NULL"
...would be totally wrong. This would actually do what you seem to be
explaining,
which would be setting a class instance to NULL, which yes, I agree is a compile
error. Again, I apologize for not being clear and posting some bad code, but
this is
clearly not the point I was trying to make.
But the above change absolutely does not break any MP4Close() usage; it is
perfectly
legal to NULL out a pointer to an object that has just been deleted.
Original comment by [email protected]
on 16 Sep 2009 at 12:07
from mp4v2.
I'll omit the typedef so you can see what's happening:
void MP4Close( void* pFile ) {
pFile = NULL; // useless as pFile is an in-parm and would do nothing to set caller's pointer
}
void MP4Close( void** ppFile ) {
*ppFile = NULL; // sets (out) pFile to NULL
}
And as mentioned earlier, this requires an incompatible change in function
signature.
Original comment by [email protected]
on 16 Sep 2009 at 12:19
from mp4v2.
Kona,
My apologies, the ** thing always throws me for a loop, but you're definitely
right.
And yes, I agree this would be a sizable change that is not worth the effort. I'll
just null out the argument after I call MP4Close like I'm currently doing.
You can close this--thanks for the help!
Original comment by [email protected]
on 16 Sep 2009 at 12:42
from mp4v2.
Original comment by [email protected]
on 22 Nov 2009 at 11:39
- Changed state: WontFix
from mp4v2.
Related Issues (20)
- MP4Info not showing information related to MJPEG Video
- Can't compile with clang
- mp4info fails to show info of the simple video taken by Android phone HOT 1
- Error when trying to compile the project mp4v2 - 2.0.0 HOT 1
- Writing tags corrupts DASH-encoded files
- Integer overflow/wraparound in \src\mp4track.cpp
- Better FileProvider API HOT 3
- Modifying tags with mp4tags -m "test" corrupts some specific MP4 files
- add compilation, gapless, and genretype tag support to mp4tags
- https://code.google.com/p/mp4v2/issues/list?can=1&q=http%3A%2F%2Flimelinx.com%2Fdswj4
- Enhancement: Fill Genre from GenreType
- "Progressive Rock" mistyped as "Progresive Rock" in src/itmf/type.cpp HOT 1
- Ability to free memory allocated by MP4GetTrackH264SeqPictHeaders function HOT 2
- Support for Track Reference Atoms HOT 1
- Import/Export mp4 tags from/to text file
- make dist fail because make doc fails HOT 2
- use of impl / private code in example utils; enumGenreType HOT 1
- Charset problem at filenames
- Generate mp4 file.Can't play by media player.
- Google Code will shut down
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mp4v2.