motioncells: fix splitting of RGB color string

No need to attempt splitting the RGB string in 255 tokens
if we only expect 3.

Left max_tokens at 4 to preserve the current logic (which
allows for extra stuff at the end) and added a warning on
parsing failure instead of silently discarding the value.
This commit is contained in:
Reynaldo H. Verdejo Pinochet 2015-12-27 22:32:22 -08:00
parent 5515a96167
commit 77b7864670

View file

@ -541,10 +541,13 @@ gst_motion_cells_set_property (GObject * object, guint prop_id,
tmply = -1;
break;
case PROP_CELLSCOLOR:
colorstr = g_strsplit (g_value_get_string (value), ",", 255);
colorstr = g_strsplit (g_value_get_string (value), ",", 4);
for (cellscolorscnt = 0; colorstr[cellscolorscnt] != NULL;
++cellscolorscnt);
if (cellscolorscnt == 3) {
if (cellscolorscnt != 3) {
GST_WARNING_OBJECT (filter, "Ignoring badly-formatted cellscolor RGB "
"string");
} else {
sscanf (colorstr[0], "%d", &r);
sscanf (colorstr[1], "%d", &g);
sscanf (colorstr[2], "%d", &b);