while (1)
{
- char * line = NULL;
- size_t len, size = 0;
+ char * line = NULL;
+ ssize_t len;
+ size_t size = 0;
len = getline(&line, &size, pv->file);
if (len < 0)
free(header);
return 1;
}
- if (len > 0)
+ if (len > 0 && line != NULL)
{
if (header != NULL)
{
{
header = strdup(line);
}
- }
- if (!events)
- {
- if (len >= events_len && !strncasecmp(line, events_tag, events_len))
- {
- events = 1;
- }
- }
- else
- {
- if (len >= format_len && !strncasecmp(line, format_tag, format_len))
+ if (!events)
{
- free(line);
- break;
+ if (len >= events_len &&
+ !strncasecmp(line, events_tag, events_len))
+ {
+ events = 1;
+ }
}
- if (len > 0)
+ else
{
+ if (len >= format_len &&
+ !strncasecmp(line, format_tag, format_len))
+ {
+ free(line);
+ break;
+ }
// Improperly formatted SSA header
free(header);
return 1;
while (!feof(pv->file))
{
- char * line = NULL;
- size_t len, size = 0;
+ char * line = NULL;
+ ssize_t len;
+ size_t size = 0;
len = getline(&line, &size, pv->file);
- if (len > 0)
+ if (len > 0 && line != NULL)
{
out = decode_line_to_mkv_ssa(pv, line, len);
if (out != NULL)