diff options
author | Sjoerd Mullender <sjoerd@acm.org> | 1993-02-10 13:31:01 (GMT) |
---|---|---|
committer | Sjoerd Mullender <sjoerd@acm.org> | 1993-02-10 13:31:01 (GMT) |
commit | 38a22baea90f0a840defe60bed46a3bc0b5973ca (patch) | |
tree | b4c8d36d3825395b4b50ea7de990a78b0fbfb28d | |
parent | 55cea47bae274334acb52910efef1a9e1e3ab759 (diff) | |
download | cpython-38a22baea90f0a840defe60bed46a3bc0b5973ca.zip cpython-38a22baea90f0a840defe60bed46a3bc0b5973ca.tar.gz cpython-38a22baea90f0a840defe60bed46a3bc0b5973ca.tar.bz2 |
Fixed some memory leaks when things go wrong.
-rw-r--r-- | Modules/audioop.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Modules/audioop.c b/Modules/audioop.c index 792c4ae..f8810d3 100644 --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -731,11 +731,6 @@ audioop_lin2adpcm3(self, args) return 0; } - str = newsizedstringobject(NULL, len/size); - if ( str == 0 ) - return 0; - ncp = (signed char *)getstringvalue(str); - /* Decode state, should have (value, step) */ if ( state == None ) { /* First time, it seems. Set defaults */ @@ -744,6 +739,11 @@ audioop_lin2adpcm3(self, args) } else if ( !getargs(state, "(ii)", &valprev, &step) ) return 0; + str = newsizedstringobject(NULL, len/size); + if ( str == 0 ) + return 0; + ncp = (signed char *)getstringvalue(str); + for ( i=0; i < len; i += size ) { if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; else if ( size == 2 ) val = (int)*SHORTP(cp, i); @@ -861,11 +861,6 @@ audioop_lin2adpcm(self, args) return 0; } - str = newsizedstringobject(NULL, len/(size*2)); - if ( str == 0 ) - return 0; - ncp = (signed char *)getstringvalue(str); - /* Decode state, should have (value, step) */ if ( state == None ) { /* First time, it seems. Set defaults */ @@ -875,6 +870,11 @@ audioop_lin2adpcm(self, args) } else if ( !getargs(state, "(ii)", &valpred, &index) ) return 0; + str = newsizedstringobject(NULL, len/(size*2)); + if ( str == 0 ) + return 0; + ncp = (signed char *)getstringvalue(str); + step = stepsizeTable[index]; bufferstep = 1; |