]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aft.c
prebuffer: Remove buffer tree node on errors.
[paraslash.git] / aft.c
diff --git a/aft.c b/aft.c
index f41bfadea25385c4ab1c9a169a15b0c755440c98..eb955e019f538e3d73f38074ff657c9b86d2199d 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -407,7 +407,7 @@ static void load_chunk_table(struct afh_info *afhi, const struct osl_object *ct)
        int i;
        size_t sz;
 
-       if (!ct->data || ct->size < 4) {
+       if (!ct->data || ct->size < 4 * (afhi->chunks_total + 1)) {
                afhi->chunk_table = NULL;
                return;
        }
@@ -589,8 +589,10 @@ static int get_hash_of_row(const struct osl_row *row, unsigned char **hash)
 int get_afhi_of_row(const struct osl_row *row, struct afh_info *afhi)
 {
        struct osl_object obj;
-       int ret = osl(osl_get_object(audio_file_table, row, AFTCOL_AFHI,
-               &obj));
+       int ret;
+
+       assert(row);
+       ret = osl(osl_get_object(audio_file_table, row, AFTCOL_AFHI, &obj));
        if (ret < 0)
                return ret;
        load_afhi(obj.data, afhi);
@@ -2620,8 +2622,10 @@ static int aft_event_handler(enum afs_events event, struct para_buffer *pb,
                /*
                 * These events are rare. We don't bother to check whether the
                 * current status items are affected and simply recreate them
-                * every time.
+                * whenever an audio file is open.
                 */
+               if (!current_aft_row)
+                       return 0;
                ret = get_afhi_of_row(current_aft_row,
                        &status_item_ls_data.afhi);
                if (ret < 0)