From 43d11aa41defbe5aea664935d5c95eac1a90bd39 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 14 Jun 2007 19:07:34 +1000 Subject: [PATCH] src/sndfile.hh : Fix constructor so subsequent calls to other methods don't segfault. --- ChangeLog | 9 +++++++++ doc/development.html | 6 +++--- reconfigure.mk | 5 +++-- src/sndfile.hh | 23 +++++++---------------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 997e669c..828809d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-06-14 Erik de Castro Lopo + + * 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 * tests/util.tpl diff --git a/doc/development.html b/doc/development.html index 81397fe6..61fbda42 100644 --- a/doc/development.html +++ b/doc/development.html @@ -34,8 +34,8 @@ it on windows.

The main archive archive can be found at: - - http://www.mega-nerd.com/Bzr/libsndfile-mdev/ + + http://www.mega-nerd.com/Bzr/libsndfile-pub/

@@ -44,7 +44,7 @@ you can do:

-	bzr get http://www.mega-nerd.com/Bzr/libsndfile-mdev/
+	bzr get http://www.mega-nerd.com/Bzr/libsndfile-pub/
 

diff --git a/reconfigure.mk b/reconfigure.mk index 1cc9cfb3..bd65bc82 100755 --- a/reconfigure.mk +++ b/reconfigure.mk @@ -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 {} \; - diff --git a/src/sndfile.hh b/src/sndfile.hh index dcf2773b..e84054b5 100644 --- a/src/sndfile.hh +++ b/src/sndfile.hh @@ -1,5 +1,5 @@ /* -** Copyright (C) 2005,2006 Erik de Castro Lopo +** Copyright (C) 2005-2007 Erik de Castro Lopo ** ** 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 -*/