src/sndfile.hh : Fix constructor so subsequent calls to other methods don't segfault.

This commit is contained in:
Erik de Castro Lopo 2007-06-14 19:07:34 +10:00
parent a7749dc5d4
commit 43d11aa41d
4 changed files with 22 additions and 21 deletions

View File

@ -1,3 +1,12 @@
2007-06-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/cpp_test.cc
Add extra tests for when the SndfileHandle constructor fails.
* src/sndfile.hh
Make sure failure to open the file in the constructor does not allow later
calls to other methods to fail.
2007-06-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/util.tpl

View File

@ -34,8 +34,8 @@ it on windows.
<!-- pepper -->
<P>
The main archive archive can be found at:
<A HREF="http://www.mega-nerd.com/Bzr/libsndfile-mdev/">
http://www.mega-nerd.com/Bzr/libsndfile-mdev/</A>
<A HREF="http://www.mega-nerd.com/Bzr/libsndfile-pub/">
http://www.mega-nerd.com/Bzr/libsndfile-pub/</A>
</P>
<!-- pepper -->
<P>
@ -44,7 +44,7 @@ you can do:
</P>
<!-- pepper -->
<PRE>
bzr get http://www.mega-nerd.com/Bzr/libsndfile-mdev/
bzr get http://www.mega-nerd.com/Bzr/libsndfile-pub/
</PRE>
<!-- pepper -->
<P>

View File

@ -52,7 +52,8 @@ aclocal.m4: acinclude.m4
$(ACLOCAL) $(ACLOCAL_INC)
clean:
rm -f libtool ltmain.sh aclocal.m4 Makefile.in src/config.h.in config.cache config.status
rm -f libtool ltmain.sh aclocal.m4 src/config.h.in config.cache config.status
rm -rf autom4te.cache
find . -name Makefile.in -exec rm -f {} \;
find . -name .deps -type d -exec rm -rf {} \;

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2005,2006 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2005-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** All rights reserved.
**
@ -163,11 +163,10 @@ SndfileHandle::SndfileHandle (const char *path, int mode, int fmt, int chans, in
p->sfinfo.sections = 0 ;
p->sfinfo.seekable = 0 ;
if ((p->sf = sf_open (path, mode, &p->sfinfo)) == NULL)
{ delete p ;
p = NULL ;
} ;
p->sf = sf_open (path, mode, &p->sfinfo) ;
} ;
return ;
} /* SndfileHandle const char * constructor */
inline
@ -186,11 +185,10 @@ SndfileHandle::SndfileHandle (std::string const & path, int mode, int fmt, int c
p->sfinfo.sections = 0 ;
p->sfinfo.seekable = 0 ;
if ((p->sf = sf_open (path.c_str (), mode, &p->sfinfo)) == NULL)
{ delete p ;
p = NULL ;
} ;
p->sf = sf_open (path.c_str (), mode, &p->sfinfo) ;
} ;
return ;
} /* SndfileHandle std::string constructor */
inline
@ -342,10 +340,3 @@ SndfileHandle::writeRaw (const void *ptr, sf_count_t bytes)
#endif /* SNDFILE_HH */
/*
** Do not edit or modify anything in this comment block.
** The following line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: a0e9d996-73d7-47c4-a78d-79a3232a9eef
*/