summaryrefslogtreecommitdiffstats
path: root/libhb/deccc608sub.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-10-18 09:22:22 -0700
committerJohn Stebbins <[email protected]>2016-10-18 09:23:15 -0700
commit19b0ddf3ff846337738a2398459656bcd8f66fe9 (patch)
tree53c027da830913a7210e5e571eba878b58e445fe /libhb/deccc608sub.c
parent63d6c558c067870ad9c4054a2b0ee678aae448c3 (diff)
deccc608sub: fix crash caused by invalid CC stream
Diffstat (limited to 'libhb/deccc608sub.c')
-rw-r--r--libhb/deccc608sub.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/libhb/deccc608sub.c b/libhb/deccc608sub.c
index 03c544f20..58ae54593 100644
--- a/libhb/deccc608sub.c
+++ b/libhb/deccc608sub.c
@@ -24,8 +24,6 @@ static int debug_608 = 0;
static int cc_channel = 1;
static int subs_delay = 0;
-#define fatal(N, ...) // N
-
int rowdata[] = {11,-1,1,2,3,4,12,13,14,15,5,6,7,8,9,10};
// Relationship between the first PAC byte and the row number
@@ -734,10 +732,11 @@ static struct eia608_screen *get_writing_buffer(struct s_write *wb)
case MODE_ROLLUP_2: // Write directly to screen
case MODE_ROLLUP_3:
case MODE_ROLLUP_4:
+ case MODE_TEXT:
use_buffer = get_current_visible_buffer(wb);
break;
default:
- fatal (EXIT_BUG_BUG, "Caption mode has an illegal value at get_writing_buffer(), this is a bug.\n");
+ hb_error("Caption mode has an illegal value at get_writing_buffer(), this is a bug.");
}
return use_buffer;
}
@@ -747,17 +746,20 @@ static void write_char(const unsigned char c, struct s_write *wb)
if (wb->data608->mode != MODE_TEXT)
{
struct eia608_screen * use_buffer = get_writing_buffer(wb);
- /* hb_log ("\rWriting char [%c] at %s:%d:%d\n",c,
- use_buffer == &wb->data608->buffer1?"B1":"B2",
- wb->data608->cursor_row,wb->data608->cursor_column); */
- use_buffer->characters[wb->data608->cursor_row][wb->data608->cursor_column] = c;
- use_buffer->colors[wb->data608->cursor_row][wb->data608->cursor_column] = wb->data608->color;
- use_buffer->fonts[wb->data608->cursor_row][wb->data608->cursor_column] = wb->data608->font;
- use_buffer->row_used[wb->data608->cursor_row] = 1;
- use_buffer->empty = 0;
- if (wb->data608->cursor_column < 31)
- wb->data608->cursor_column++;
- use_buffer->dirty = 1;
+ if (use_buffer != NULL)
+ {
+ /* hb_log ("\rWriting char [%c] at %s:%d:%d\n",c,
+ use_buffer == &wb->data608->buffer1?"B1":"B2",
+ wb->data608->cursor_row,wb->data608->cursor_column); */
+ use_buffer->characters[wb->data608->cursor_row][wb->data608->cursor_column] = c;
+ use_buffer->colors[wb->data608->cursor_row][wb->data608->cursor_column] = wb->data608->color;
+ use_buffer->fonts[wb->data608->cursor_row][wb->data608->cursor_column] = wb->data608->font;
+ use_buffer->row_used[wb->data608->cursor_row] = 1;
+ use_buffer->empty = 0;
+ if (wb->data608->cursor_column < 31)
+ wb->data608->cursor_column++;
+ use_buffer->dirty = 1;
+ }
}
}
@@ -1213,9 +1215,12 @@ static void handle_command(unsigned char c1, const unsigned char c2,
{
struct eia608_screen *data;
data = get_writing_buffer(wb);
- wb->data608->cursor_column--;
- data->characters[wb->data608->cursor_row][wb->data608->cursor_column] = ' ';
- data->dirty = 1;
+ if (data != NULL)
+ {
+ wb->data608->cursor_column--;
+ data->characters[wb->data608->cursor_row][wb->data608->cursor_column] = ' ';
+ data->dirty = 1;
+ }
}
break;
case COM_TABOFFSET1: