diff options
author | wm4 <wm4@nowhere> | 2015-01-12 14:43:52 +0100 |
---|---|---|
committer | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2015-01-25 17:00:08 +0900 |
commit | a44ffb729b06950c08e45b4ad9522e0977751c85 (patch) | |
tree | 10bb6192492c0698fc1cab40d0174c42f4ef5db3 | |
parent | 947a791992aa8b99e7e43f9a7c35866fe2e3c2f9 (diff) | |
download | mpv-a44ffb729b06950c08e45b4ad9522e0977751c85.tar.bz2 mpv-a44ffb729b06950c08e45b4ad9522e0977751c85.tar.xz |
bstr: fix possible undefined behavior with length 0 strings
BSTR_P() passes the string length and start pointer to printf-like
functions. If the lenfth is 0, the pointer can be NULL, but we're
actually still not allowed to pass a NULL pointer in any case.
This is mostly a technically, because nobody in their right mind would
attempt to specifically break such cases. But it's still undefined
behavior, and some libcs might be strict about this.
-rw-r--r-- | misc/bstr.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/misc/bstr.h b/misc/bstr.h index a1e99dd4a5..6871da1c18 100644 --- a/misc/bstr.h +++ b/misc/bstr.h @@ -207,7 +207,7 @@ static inline int bstr_eatstart0(struct bstr *s, const char *prefix) } // create a pair (not single value!) for "%.*s" printf syntax -#define BSTR_P(bstr) (int)((bstr).len), (bstr).start +#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "") #define WHITESPACE " \f\n\r\t\v" |