From 99b198605a20e44e2eeb3744ada325dc0f9929f4 Mon Sep 17 00:00:00 2001 From: LittlePrince92 Date: Tue, 24 Jul 2018 12:14:39 +0800 Subject: [PATCH] add check of input to avoid coredump add check of input to avoid coredump --- include/cppjieba/Jieba.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/cppjieba/Jieba.hpp b/include/cppjieba/Jieba.hpp index abd321d4..d26af1a5 100644 --- a/include/cppjieba/Jieba.hpp +++ b/include/cppjieba/Jieba.hpp @@ -32,37 +32,48 @@ class Jieba { }; // struct LocWord void Cut(const string& sentence, vector& words, bool hmm = true) const { + if(sentence.empty()) return; mix_seg_.Cut(sentence, words, hmm); } void Cut(const string& sentence, vector& words, bool hmm = true) const { + if(sentence.empty()) return; mix_seg_.Cut(sentence, words, hmm); } void CutAll(const string& sentence, vector& words) const { + if(sentence.empty()) return; full_seg_.Cut(sentence, words); } void CutAll(const string& sentence, vector& words) const { + if(sentence.empty()) return; full_seg_.Cut(sentence, words); } void CutForSearch(const string& sentence, vector& words, bool hmm = true) const { + if(sentence.empty()) return; query_seg_.Cut(sentence, words, hmm); } void CutForSearch(const string& sentence, vector& words, bool hmm = true) const { + if(sentence.empty()) return; query_seg_.Cut(sentence, words, hmm); } void CutHMM(const string& sentence, vector& words) const { + if(sentence.empty()) return; hmm_seg_.Cut(sentence, words); } void CutHMM(const string& sentence, vector& words) const { + if(sentence.empty()) return; hmm_seg_.Cut(sentence, words); } void CutSmall(const string& sentence, vector& words, size_t max_word_len) const { + if(sentence.empty()) return; mp_seg_.Cut(sentence, words, max_word_len); } void CutSmall(const string& sentence, vector& words, size_t max_word_len) const { + if(sentence.empty()) return; mp_seg_.Cut(sentence, words, max_word_len); } void Tag(const string& sentence, vector >& words) const { + if(sentence.empty()) return; mix_seg_.Tag(sentence, words); } string LookupTag(const string &str) const {