diff options
author | Marco Nelissen <marcone@google.com> | 2015-05-07 15:33:21 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-05-07 15:33:21 +0000 |
commit | 4c80f99c014960a01eec978eb50ecaaef6703685 (patch) | |
tree | c50e86e609b03c68e92c6abdc770cd6a82de1be4 | |
parent | 4955bfb4caeb9b0b03b85a1e886674ddbccdb44f (diff) | |
parent | 2e941e40ce76eb13b273479a4ee8fb6e40d33795 (diff) | |
download | tremolo-4c80f99c014960a01eec978eb50ecaaef6703685.tar.gz |
am 2e941e40: Fix allocation failure crash
* commit '2e941e40ce76eb13b273479a4ee8fb6e40d33795':
Fix allocation failure crash
-rw-r--r-- | Tremolo/codebook.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Tremolo/codebook.c b/Tremolo/codebook.c index 27903b5..0ff3529 100644 --- a/Tremolo/codebook.c +++ b/Tremolo/codebook.c @@ -507,13 +507,12 @@ int vorbis_book_unpack(oggpack_buffer *opb,codebook *s){ /* use dec_type 1: vector of packed values */ /* need quantized values before */ - s->q_val=alloca(sizeof(ogg_uint16_t)*quantvals); + s->q_val=calloc(sizeof(ogg_uint16_t), quantvals); if (!s->q_val) goto _eofout; for(i=0;i<quantvals;i++) ((ogg_uint16_t *)s->q_val)[i]=(ogg_uint16_t)oggpack_read(opb,s->q_bits); if(oggpack_eop(opb)){ - s->q_val=0; /* cleanup must not free alloca memory */ goto _eofout; } @@ -523,12 +522,11 @@ int vorbis_book_unpack(oggpack_buffer *opb,codebook *s){ s->dec_leafw=_determine_leaf_words(s->dec_nodeb, (s->q_bits*s->dim+8)/8); if(_make_decode_table(s,lengthlist,quantvals,opb,maptype)){ - s->q_val=0; /* cleanup must not free alloca memory */ goto _errout; } - s->q_val=0; /* about to go out of scope; _make_decode_table - was using it */ + free(s->q_val); + s->q_val=0; }else{ /* use dec_type 2: packed vector of column offsets */ @@ -619,6 +617,7 @@ int vorbis_book_unpack(oggpack_buffer *opb,codebook *s){ _eofout: vorbis_book_clear(s); free(lengthlist); + free(s->q_val); return -1; } |