libaacs | branch: master | npzacs <[email protected]> | Fri May 29 13:39:26 2015 +0300| [c6dc792eba169e34b34f542c32066c04601cf428] | committer: npzacs
Merge string utils changes from other libs > http://git.videolan.org/gitweb.cgi/libaacs.git/?a=commit;h=c6dc792eba169e34b34f542c32066c04601cf428 --- src/util/strutl.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/util/strutl.c b/src/util/strutl.c index ae55b59..a6ef77f 100644 --- a/src/util/strutl.c +++ b/src/util/strutl.c @@ -18,6 +18,10 @@ * <http://www.gnu.org/licenses/>. */ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include "strutl.h" #include "macro.h" @@ -155,7 +159,16 @@ int hex_array_to_hexstring(char *str, const uint8_t *hex_array, uint32_t size) char *str_dup(const char *str) { - return str ? strcpy (malloc(strlen(str) + 1), str) : NULL; + char *dup = NULL; + + if (str) { + size_t size = strlen(str) + 1; + dup = malloc(size); + if (dup) { + memcpy(dup, str, size); + } + } + return dup; } char *str_printf(const char *fmt, ...) @@ -198,7 +211,7 @@ const char *str_next_line(const char *p) while (*p && *p != '\r' && *p != '\n') { p++; } - while (*p && (*p == '\r' || *p == '\n')) { + while (*p && (*p == '\r' || *p == '\n' || *p == ' ')) { p++; } _______________________________________________ libaacs-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libaacs-devel
