From b67441babb6856f4d1e83f3072886425b1ee83d4 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 5 Feb 2013 11:01:43 +0000 Subject: [PATCH] =?UTF-8?q?sys:=20be=20more=20resilient=20if=20the=20file?= =?UTF-8?q?=20we=20try=20to=20read=20doesn=E2=80=99t=20exist.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sys/file.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sys/file.cpp b/src/sys/file.cpp index abad7ffb..bd9cb576 100644 --- a/src/sys/file.cpp +++ b/src/sys/file.cpp @@ -35,7 +35,7 @@ class FileData String ret; #if __CELLOS_LV2__ #elif HAVE_STDIO_H - while (!feof(m_fd)) + while (m_fd && !feof(m_fd)) { char buf[BUFSIZ]; size_t count = fread(buf, 1, BUFSIZ, m_fd); @@ -54,7 +54,9 @@ class FileData { #if __CELLOS_LV2__ #elif HAVE_STDIO_H - fclose(m_fd); + if (m_fd) + fclose(m_fd); + m_fd = NULL; #endif }