From 58fb13cdd772ad9f2e7088f2f524d40ab1efa896 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 3 Apr 2014 22:12:49 -0700 Subject: [PATCH] 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. --- src/libpspp/line-reader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.30.2