Commit 33ad3513 authored by Brendan Long's avatar Brendan Long

Merge pull request #143 from aChinKaiWu/master

Fix crash when playspeed count reaches PLAYSPEEDS_MAX_CNT Plugin crashed when playspeed count reaches PLAYSPEEDS_MAX_CNT
parents 8990bdd4 69abe94e
...@@ -839,7 +839,8 @@ dlna_src_handle_query_seeking (GstDlnaSrc * dlna_src, GstQuery * query) ...@@ -839,7 +839,8 @@ dlna_src_handle_query_seeking (GstDlnaSrc * dlna_src, GstQuery * query)
GST_INFO_OBJECT (dlna_src, GST_INFO_OBJECT (dlna_src,
"Seeking in bytes not available for content item"); "Seeking in bytes not available for content item");
gst_query_set_seeking (query, GST_FORMAT_BYTES, FALSE, seek_start, seek_end); gst_query_set_seeking (query, GST_FORMAT_BYTES, FALSE, seek_start,
seek_end);
ret = TRUE; ret = TRUE;
} }
} else if (format == GST_FORMAT_TIME) { } else if (format == GST_FORMAT_TIME) {
...@@ -858,7 +859,8 @@ dlna_src_handle_query_seeking (GstDlnaSrc * dlna_src, GstQuery * query) ...@@ -858,7 +859,8 @@ dlna_src_handle_query_seeking (GstDlnaSrc * dlna_src, GstQuery * query)
GST_DEBUG_OBJECT (dlna_src, GST_DEBUG_OBJECT (dlna_src,
"Seeking in media time not available for content item"); "Seeking in media time not available for content item");
gst_query_set_seeking (query, GST_FORMAT_TIME, FALSE, seek_start, seek_end); gst_query_set_seeking (query, GST_FORMAT_TIME, FALSE, seek_start,
seek_end);
ret = TRUE; ret = TRUE;
} }
} else { } else {
...@@ -2044,6 +2046,8 @@ dlna_src_head_response_free_struct (GstDlnaSrc * dlna_src, ...@@ -2044,6 +2046,8 @@ dlna_src_head_response_free_struct (GstDlnaSrc * dlna_src,
if (head_response->content_features) { if (head_response->content_features) {
g_free (head_response->content_features->profile); g_free (head_response->content_features->profile);
/* Reset playspeeds_cnt in case of invalid g_free when PLAYSPEEDS_MAX_CNT reached */
head_response->content_features->playspeeds_cnt = 0;
for (i = 0; i < PLAYSPEEDS_MAX_CNT; i++) for (i = 0; i < PLAYSPEEDS_MAX_CNT; i++)
g_free (head_response->content_features->playspeed_strs[i]); g_free (head_response->content_features->playspeed_strs[i]);
...@@ -2920,6 +2924,7 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src, ...@@ -2920,6 +2924,7 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
gfloat rate = 0; gfloat rate = 0;
int d; int d;
int n; int n;
int i;
gchar **tokens; gchar **tokens;
gchar **ptr; gchar **ptr;
...@@ -2933,6 +2938,13 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src, ...@@ -2933,6 +2938,13 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
} else { } else {
GST_LOG_OBJECT (dlna_src, "PS Field value: %s", tmp2); GST_LOG_OBJECT (dlna_src, "PS Field value: %s", tmp2);
/* Release playspeeds string */
for (i = 0; i < head_response->content_features->playspeeds_cnt; i++) {
g_free (head_response->content_features->playspeed_strs[i]);
}
/* Reset playspeeds count */
head_response->content_features->playspeeds_cnt = 0;
/* Tokenize list of comma separated playspeeds */ /* Tokenize list of comma separated playspeeds */
tokens = g_strsplit (tmp2, ",", PLAYSPEEDS_MAX_CNT); tokens = g_strsplit (tmp2, ",", PLAYSPEEDS_MAX_CNT);
for (ptr = tokens; *ptr; ptr++) { for (ptr = tokens; *ptr; ptr++) {
...@@ -2940,8 +2952,6 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src, ...@@ -2940,8 +2952,6 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
GST_LOG_OBJECT (dlna_src, "Found PS: %s", *ptr); GST_LOG_OBJECT (dlna_src, "Found PS: %s", *ptr);
/* Store string representation to facilitate fractional string conversion */ /* Store string representation to facilitate fractional string conversion */
g_free (head_response->content_features->playspeed_strs
[head_response->content_features->playspeeds_cnt]);
head_response->content_features->playspeed_strs head_response->content_features->playspeed_strs
[head_response->content_features->playspeeds_cnt] [head_response->content_features->playspeeds_cnt]
= g_strdup (*ptr); = g_strdup (*ptr);
...@@ -2954,9 +2964,8 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src, ...@@ -2954,9 +2964,8 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
"Problems converting playspeed %s into numeric value", *ptr); "Problems converting playspeed %s into numeric value", *ptr);
return FALSE; return FALSE;
} else { } else {
head_response->content_features-> head_response->content_features->playspeeds[head_response->
playspeeds[head_response->content_features->playspeeds_cnt] = content_features->playspeeds_cnt] = rate;
rate;
} }
} else { } else {
/* Handle conversion of fractional string into float, needed when specifying rate */ /* Handle conversion of fractional string into float, needed when specifying rate */
...@@ -2968,12 +2977,14 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src, ...@@ -2968,12 +2977,14 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
} else { } else {
rate = (gfloat) n / (gfloat) d; rate = (gfloat) n / (gfloat) d;
head_response->content_features-> head_response->content_features->playspeeds[head_response->
playspeeds[head_response->content_features->playspeeds_cnt] = content_features->playspeeds_cnt] = rate;
rate;
} }
} }
head_response->content_features->playspeeds_cnt++; head_response->content_features->playspeeds_cnt++;
if (head_response->content_features->playspeeds_cnt >=
PLAYSPEEDS_MAX_CNT)
continue;
} }
} }
g_strfreev (tokens); g_strfreev (tokens);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment