From: Ben Pfaff Date: Fri, 4 Apr 2014 05:12:49 +0000 (-0700) Subject: line-reader: Fix null derefe in line_reader_for_fd() with null encoding. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58fb13cdd772ad9f2e7088f2f524d40ab1efa896;hp=b20b80bfeb88eca603cb5c10b5a7188387fd23fd;p=pspp line-reader: Fix null derefe in line_reader_for_fd() with null encoding. This function is supposed to treat NULL and "Auto" the same way, but it tried to xstrdup NULL, which doesn't work. This is easy to reproduce by attempting to use File|Import Data to read a short file whose contents are all ASCII. Bug #41971. Reported by Mindaugus. --- diff --git a/src/libpspp/line-reader.c b/src/libpspp/line-reader.c index 56a368da29..cb4bd014b9 100644 --- a/src/libpspp/line-reader.c +++ b/src/libpspp/line-reader.c @@ -125,7 +125,7 @@ line_reader_for_fd (const char *encoding, int fd) && !strcmp (r->encoding, "ASCII")) { r->state = S_AUTO; - r->auto_encoding = xstrdup (encoding); + r->auto_encoding = encoding ? xstrdup (encoding) : NULL; } else r->state = r->encoding_info.unit == 1 ? S_UNIBYTE : S_MULTIBYTE;