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:
@@ -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
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
Reference in New Issue
Block a user