From 38a22baea90f0a840defe60bed46a3bc0b5973ca Mon Sep 17 00:00:00 2001 From: Sjoerd Mullender Date: Wed, 10 Feb 1993 13:31:01 +0000 Subject: [PATCH] Fixed some memory leaks when things go wrong. --- Modules/audioop.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/audioop.c b/Modules/audioop.c index 792c4ae91fa..f8810d3eb31 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;