mirror of https://github.com/python/cpython
Fixed some memory leaks when things go wrong.
This commit is contained in:
parent
55cea47bae
commit
38a22baea9
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue