Check output availability
authorMathis Rosenhauer <rosenhauer@dkrz.de>
Tue, 20 Nov 2012 16:26:43 +0000 (17:26 +0100)
committerThomas Jahns <jahns@dkrz.de>
Tue, 19 Feb 2013 10:33:00 +0000 (11:33 +0100)
src/encode.c

index cc7eae1..612d33a 100644 (file)
@@ -605,11 +605,12 @@ static int m_get_rsi_resumable(struct aec_stream *strm)
                     }
 
                     emit(state, 0, state->bits);
-                    if (state->direct_out == 0)
-                        *strm->next_out++ = *state->cds;
-                    strm->avail_out--;
-                    strm->total_out++;
-
+                    if (strm->avail_out > 0) {
+                        if (state->direct_out == 0)
+                            *strm->next_out++ = *state->cds;
+                        strm->avail_out--;
+                        strm->total_out++;
+                    }
                     return M_EXIT;
                 }
             } else {