Fix: use index, not cur_index, for SEEK_SET validation
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 17 Jun 2013 19:48:55 +0000 (15:48 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 17 Jun 2013 19:48:55 +0000 (15:48 -0400)
Fixes #551

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c

index bb94e52770e36641fd8107414229992426ec1e58..752b548e766d37bc60cf3fc21215f10eb894fc55 100644 (file)
@@ -729,14 +729,6 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
                pos->offset = 0;
        } else {
        read_next_packet:
-               if (pos->cur_index >= pos->packet_cycles_index->len) {
-                       pos->offset = EOF;
-                       return;
-               }
-               if (pos->cur_index >= pos->packet_real_index->len) {
-                       pos->offset = EOF;
-                       return;
-               }
                switch (whence) {
                case SEEK_CUR:
                {
@@ -745,6 +737,9 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
                        if (pos->offset == EOF) {
                                return;
                        }
+                       assert(pos->cur_index < pos->packet_cycles_index->len);
+                       assert(pos->cur_index < pos->packet_real_index->len);
+
                        /* For printing discarded event count */
                        packet_index = &g_array_index(pos->packet_cycles_index,
                                        struct packet_index, pos->cur_index);
@@ -782,6 +777,10 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence)
                        break;
                }
                case SEEK_SET:
+                       if (index >= pos->packet_cycles_index->len) {
+                               pos->offset = EOF;
+                               return;
+                       }
                        packet_index = &g_array_index(pos->packet_cycles_index,
                                        struct packet_index, index);
                        pos->last_events_discarded = packet_index->events_discarded;
This page took 0.025971 seconds and 4 git commands to generate.