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)
GST_INFO_OBJECT (dlna_src,
"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;
}
} else if (format == GST_FORMAT_TIME) {
......@@ -858,7 +859,8 @@ dlna_src_handle_query_seeking (GstDlnaSrc * dlna_src, GstQuery * query)
GST_DEBUG_OBJECT (dlna_src,
"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;
}
} else {
......@@ -2044,6 +2046,8 @@ dlna_src_head_response_free_struct (GstDlnaSrc * dlna_src,
if (head_response->content_features) {
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++)
g_free (head_response->content_features->playspeed_strs[i]);
......@@ -2920,6 +2924,7 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
gfloat rate = 0;
int d;
int n;
int i;
gchar **tokens;
gchar **ptr;
......@@ -2933,6 +2938,13 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
} else {
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 */
tokens = g_strsplit (tmp2, ",", PLAYSPEEDS_MAX_CNT);
for (ptr = tokens; *ptr; ptr++) {
......@@ -2940,8 +2952,6 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
GST_LOG_OBJECT (dlna_src, "Found PS: %s", *ptr);
/* 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->playspeeds_cnt]
= g_strdup (*ptr);
......@@ -2954,9 +2964,8 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
"Problems converting playspeed %s into numeric value", *ptr);
return FALSE;
} else {
head_response->content_features->
playspeeds[head_response->content_features->playspeeds_cnt] =
rate;
head_response->content_features->playspeeds[head_response->
content_features->playspeeds_cnt] = rate;
}
} else {
/* Handle conversion of fractional string into float, needed when specifying rate */
......@@ -2968,12 +2977,14 @@ dlna_src_head_response_parse_playspeeds (GstDlnaSrc * dlna_src,
} else {
rate = (gfloat) n / (gfloat) d;
head_response->content_features->
playspeeds[head_response->content_features->playspeeds_cnt] =
rate;
head_response->content_features->playspeeds[head_response->
content_features->playspeeds_cnt] = rate;
}
}
head_response->content_features->playspeeds_cnt++;
if (head_response->content_features->playspeeds_cnt >=
PLAYSPEEDS_MAX_CNT)
continue;
}
}
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