Commit b53e80d7 authored by Max Kellermann's avatar Max Kellermann

modplug: use GByteArray.len, remove total_len

The local variable "total_len" is superfluous because GByteArray always knows its size.
parent 0c716405
...@@ -35,7 +35,6 @@ static GByteArray *mod_loadfile(struct decoder *decoder, struct input_stream *is ...@@ -35,7 +35,6 @@ static GByteArray *mod_loadfile(struct decoder *decoder, struct input_stream *is
{ {
unsigned char *data; unsigned char *data;
GByteArray *bdatas; GByteArray *bdatas;
int total_len;
int ret; int ret;
if (is->size == 0) { if (is->size == 0) {
...@@ -56,17 +55,16 @@ static GByteArray *mod_loadfile(struct decoder *decoder, struct input_stream *is ...@@ -56,17 +55,16 @@ static GByteArray *mod_loadfile(struct decoder *decoder, struct input_stream *is
} }
data = g_malloc(MODPLUG_READ_BLOCK); data = g_malloc(MODPLUG_READ_BLOCK);
total_len = 0;
do { do {
ret = decoder_read(decoder, is, data, MODPLUG_READ_BLOCK); ret = decoder_read(decoder, is, data, MODPLUG_READ_BLOCK);
if (ret > 0) { if (ret > 0) {
g_byte_array_append(bdatas, data, ret); g_byte_array_append(bdatas, data, ret);
total_len += ret;
} else { } else {
//end of file, or read error //end of file, or read error
break; break;
} }
if (total_len > MODPLUG_FILE_LIMIT) {
if (bdatas->len > MODPLUG_FILE_LIMIT) {
g_warning("stream too large\n"); g_warning("stream too large\n");
g_free(data); g_free(data);
g_byte_array_free(bdatas, TRUE); g_byte_array_free(bdatas, TRUE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment