Test string==0 once before looping. Avoid testing inside the loop.
Test reject==0 once before looping. Avoid testing inside the loop.

Signed-off-by: Jose Da Silva <digi...@joescat.com>
---
 libavcodec/xpmdec.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c
index 5aab46c52d..92a568041c 100644
--- a/libavcodec/xpmdec.c
+++ b/libavcodec/xpmdec.c
@@ -213,22 +213,24 @@ static size_t mod_strcspn(const char *string, const char 
*reject)
 {
     int i, j;

-    for (i = 0; string && string[i]; i++) {
+    if (string == 0)
+        return 0;
+    for (i = 0; string[i]; i++) {
         if (string[i] == '/' && string[i+1] == '*') {
             i += 2;
-            while ( string && string[i] && (string[i] != '*' || string[i+1] != 
'/') )
+            while (string[i] && (string[i] != '*' || string[i+1] != '/'))
                 i++;
             i++;
         } else if (string[i] == '/' && string[i+1] == '/') {
             i += 2;
-            while ( string && string[i] && string[i] != '\n' )
+            while (string[i] && string[i] != '\n')
                 i++;
-        } else {
-            for (j = 0; reject && reject[j]; j++) {
+        } else if (reject) {
+            for (j = 0; reject[j]; j++) {
                 if (string[i] == reject[j])
                     break;
             }
-            if (reject && reject[j])
+            if (reject[j])
                 break;
         }
     }
--
2.30.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to