lavfi: issue error if maximum number of filters is reached
authorStefano Sabatini <stefasab@gmail.com>
Wed, 2 Nov 2011 21:08:28 +0000 (22:08 +0100)
committerStefano Sabatini <stefasab@gmail.com>
Sat, 5 Nov 2011 01:13:37 +0000 (02:13 +0100)
Issue an error and return a more meaningful error code in case the
maximum number of registered filters has been reached.
This is better than silently ignore the error, improve feedback.

libavfilter/avfilter.c

index c1b7c43..d5f0c4b 100644 (file)
@@ -706,8 +706,13 @@ AVFilter *avfilter_get_by_name(const char *name)
 
 int avfilter_register(AVFilter *filter)
 {
-    if (next_registered_avfilter_idx == MAX_REGISTERED_AVFILTERS_NB)
-        return -1;
+    if (next_registered_avfilter_idx == MAX_REGISTERED_AVFILTERS_NB) {
+        av_log(NULL, AV_LOG_ERROR,
+               "Maximum number of registered filters %d reached, "
+               "impossible to register filter with name '%s'\n",
+               MAX_REGISTERED_AVFILTERS_NB, filter->name);
+        return AVERROR(ENOMEM);
+    }
 
     registered_avfilters[next_registered_avfilter_idx++] = filter;
     return 0;