From 99e0da52b65e7549a660616b111e294c313315e3 Mon Sep 17 00:00:00 2001 From: chrox Date: Tue, 22 Oct 2013 22:13:42 +0800 Subject: [PATCH] check json output before decoding This should fix #332. --- frontend/ui/reader/readerdictionary.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/ui/reader/readerdictionary.lua b/frontend/ui/reader/readerdictionary.lua index ef3f512c9..dffc1c404 100644 --- a/frontend/ui/reader/readerdictionary.lua +++ b/frontend/ui/reader/readerdictionary.lua @@ -20,7 +20,8 @@ function ReaderDictionary:stardictLookup(word) DEBUG("stripped word:", word) -- escape quotes and other funny characters in word local std_out = io.popen("./sdcv --utf8-input --utf8-output -nj "..("%q"):format(word), "r") - local results_str = std_out:read("*all") + local results_str = nil + if std_out then results_str = std_out:read("*all") end if results_str then --DEBUG("result str:", word, results_str) local ok, results = pcall(JSON.decode, JSON, results_str)