shithub: dumb

Download patch

ref: 33cd2c469ae9872dd0710297760bfb1dfe53a56d
parent: e169b25f34ca140da8375a7085791447a5b8e8e8
author: Chris Moeller <[email protected]>
date: Wed Jan 19 10:20:02 EST 2011

- Made Oktalyzer reader more tolerant of truncated files
- Version is now 0.9.9.30

git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C562

--- a/dumb/src/it/readokt.c
+++ b/dumb/src/it/readokt.c
@@ -230,6 +230,8 @@
 		chunk->type = bytes_read;
 		chunk->size = dumbfile_mgetl( f );
 
+		if ( dumbfile_error( f ) ) break;
+
 		chunk->data = (unsigned char *) malloc( chunk->size );
 		if ( !chunk->data )
 		{
@@ -241,14 +243,25 @@
 		bytes_read = dumbfile_getnc( ( char * ) chunk->data, chunk->size, f );
 		if ( bytes_read < chunk->size )
 		{
-			free( mod->chunks );
-			free( mod );
-			return NULL;
+			if ( bytes_read <= 0 ) {
+				free( chunk->data );
+				break;
+			} else {
+				chunk->size = bytes_read;
+				mod->chunk_count++;
+				break;
+			}
 		}
 
 		mod->chunk_count++;
 	}
 
+	if ( !mod->chunk_count ) {
+		if ( mod->chunks ) free(mod->chunks);
+		free(mod);
+		mod = NULL;
+	}
+
 	return mod;
 }
 
@@ -483,6 +496,9 @@
 			}
 			j++;
 		}
+	}
+	for (; i < sigdata->n_samples; i++) {
+		sigdata->sample[i].flags = 0;
 	}
 
 	chunk = get_chunk_by_type(mod, DUMB_ID('C','M','O','D'), 0);