From e97447609902cb232a92f824ecf2574678357e1a Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 2 Mar 2017 20:43:04 -0800 Subject: [PATCH] A crash will be triggered in evernote plugin if a history file is empty (#2604) --- plugins/evernote.koplugin/clip.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/evernote.koplugin/clip.lua b/plugins/evernote.koplugin/clip.lua index f5a72153b..c6c5d3a10 100644 --- a/plugins/evernote.koplugin/clip.lua +++ b/plugins/evernote.koplugin/clip.lua @@ -1,6 +1,7 @@ local DocumentRegistry = require("document/documentregistry") local DocSettings = require("docsettings") local ReadHistory = require("readhistory") +local logger = require("logger") local md5 = require("ffi/MD5") local util = require("util") @@ -263,7 +264,16 @@ function MyClipping:parseHistoryFile(clippings, history_file, doc_file) end if lfs.attributes(doc_file, "mode") ~= "file" then return end local ok, stored = pcall(dofile, history_file) - if ok and stored.highlight then + if ok then + if not stored then + logger.warn("An empty history file ", + history_file, + "has been found. The book associated is ", + doc_file) + return + elseif not stored.highlight then + return + end local _, docname = util.splitFilePathName(doc_file) local title, author = self:getTitle(util.splitFileNameSuffix(docname)) clippings[title] = {