Revision 2722dd6e libavfilter/parseutils.c

View differences:

libavfilter/parseutils.c
183 183

  
184 184
#define ALPHA_SEP '@'
185 185

  
186
int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx)
186
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
187
                   void *log_ctx)
187 188
{
188 189
    char *tail, color_string2[128];
189 190
    const ColorEntry *entry;
......
194 195
    } else if (!strncmp(color_string, "0x", 2))
195 196
        hex_offset = 2;
196 197

  
197
    av_strlcpy(color_string2, color_string + hex_offset, sizeof(color_string2));
198
    if (slen < 0)
199
        slen = strlen(color_string);
200
    av_strlcpy(color_string2, color_string + hex_offset,
201
               FFMIN(slen-hex_offset+1, sizeof(color_string2)));
198 202
    if ((tail = strchr(color_string2, ALPHA_SEP)))
199 203
        *tail++ = 0;
200 204
    len = strlen(color_string2);
......
308 312
        av_log_set_level(AV_LOG_DEBUG);
309 313

  
310 314
        for (i = 0;  i < FF_ARRAY_ELEMS(color_names); i++) {
311
            if (av_parse_color(rgba, color_names[i], NULL) >= 0)
315
            if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0)
312 316
                printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]);
313 317
        }
314 318
    }

Also available in: Unified diff