From: Bruno Haible Date: Fri, 10 Apr 2020 19:19:36 +0000 (+0200) Subject: xgettext: Fix a report by an undefined-behaviour sanitizer. X-Git-Tag: v0.20.2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1cc232c794c861a893ec4fbf7f2d06a1c142ea98;p=thirdparty%2Fgettext.git xgettext: Fix a report by an undefined-behaviour sanitizer. Reported by Jeffrey Walton in . * gettext-tools/src/read-properties.c (read_escaped_string): Don't call memcpy with a NULL argument. --- diff --git a/gettext-tools/src/read-properties.c b/gettext-tools/src/read-properties.c index 8b6c84a04..4dcb8aaeb 100644 --- a/gettext-tools/src/read-properties.c +++ b/gettext-tools/src/read-properties.c @@ -1,5 +1,5 @@ /* Reading Java .properties files. - Copyright (C) 2003, 2005-2007, 2009, 2018 Free Software Foundation, Inc. + Copyright (C) 2003, 2005-2007, 2009, 2018, 2020 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software: you can redistribute it and/or modify @@ -582,7 +582,8 @@ read_escaped_string (bool in_key) /* Return the result. */ { unsigned char *utf8_string = XNMALLOC (utf8_buflen + 1, unsigned char); - memcpy (utf8_string, utf8_buffer, utf8_buflen); + if (utf8_buflen > 0) + memcpy (utf8_string, utf8_buffer, utf8_buflen); utf8_string[utf8_buflen] = '\0'; return (char *) utf8_string;