[FFmpeg-devel] [PATCH] rtsp.c small cleanups

Ronald S. Bultje rsbultje
Mon Mar 23 23:28:22 CET 2009


Hi,

On Mon, Mar 23, 2009 at 3:43 PM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> This has a nasty side-effect (issue-919) that strchr(string, '\0')
> returns the end of string instead of NULL, and that is sort of not
> what I hoped for. As a result of this, redir_isspace('\0') expands to
> strchr(" \r\t\n", '\0'); returns the end of the string instead of
> NULL. Attached patch fixes that. I don't quite like this solution and
> would like to hear if there's anything like strnchr() or so, or a way
> to fix strchr() to not go beyond the end-of-string.

memchr() appears to work.

Ronald
-------------- next part --------------
Index: ffmpeg-svn/libavformat/rtsp.c
===================================================================
--- ffmpeg-svn.orig/libavformat/rtsp.c	2009-03-23 14:51:11.000000000 -0400
+++ ffmpeg-svn/libavformat/rtsp.c	2009-03-23 18:27:21.000000000 -0400
@@ -55,7 +55,7 @@
 }
 
 #define SPACE_CHARS " \t\r\n"
-#define redir_isspace(c) strchr(SPACE_CHARS, c)
+#define redir_isspace(c) memchr(SPACE_CHARS, c, 4)
 static void skip_spaces(const char **pp)
 {
     const char *p;



More information about the ffmpeg-devel mailing list