We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5c951c5 commit 2e84090Copy full SHA for 2e84090
python/cthainlp_wrapper.c
@@ -6,6 +6,7 @@
6
#define PY_SSIZE_T_CLEAN
7
#include <Python.h>
8
#include <string.h>
9
+#include <stdlib.h>
10
#include "newmm.h"
11
12
/* Module-level dictionary cache */
@@ -52,6 +53,12 @@ static newmm_dict_t get_or_load_dict(const char* dict_path) {
52
53
dict_cache.dict = newmm_load_dict(dict_path);
54
if (dict_cache.dict && dict_path) {
55
dict_cache.dict_path = strdup(dict_path);
56
+ if (!dict_cache.dict_path) {
57
+ /* strdup failed, clean up and return NULL */
58
+ newmm_free_dict(dict_cache.dict);
59
+ dict_cache.dict = NULL;
60
+ return NULL;
61
+ }
62
}
63
64
0 commit comments