modplug: use GByteArray.len, remove total_len
The local variable "total_len" is superfluous because GByteArray always knows its size.
This commit is contained in:
parent
0c71640528
commit
b53e80d785
|
@ -35,7 +35,6 @@ static GByteArray *mod_loadfile(struct decoder *decoder, struct input_stream *is
|
|||
{
|
||||
unsigned char *data;
|
||||
GByteArray *bdatas;
|
||||
int total_len;
|
||||
int ret;
|
||||
|
||||
if (is->size == 0) {
|
||||
|
@ -56,17 +55,16 @@ static GByteArray *mod_loadfile(struct decoder *decoder, struct input_stream *is
|
|||
}
|
||||
|
||||
data = g_malloc(MODPLUG_READ_BLOCK);
|
||||
total_len = 0;
|
||||
do {
|
||||
ret = decoder_read(decoder, is, data, MODPLUG_READ_BLOCK);
|
||||
if (ret > 0) {
|
||||
g_byte_array_append(bdatas, data, ret);
|
||||
total_len += ret;
|
||||
} else {
|
||||
//end of file, or read error
|
||||
break;
|
||||
}
|
||||
if (total_len > MODPLUG_FILE_LIMIT) {
|
||||
|
||||
if (bdatas->len > MODPLUG_FILE_LIMIT) {
|
||||
g_warning("stream too large\n");
|
||||
g_free(data);
|
||||
g_byte_array_free(bdatas, TRUE);
|
||||
|
|
Loading…
Reference in New Issue