summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hangul/hanja.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/hangul/hanja.c b/hangul/hanja.c
index 84c57b0..0cc7349 100644
--- a/hangul/hanja.c
+++ b/hangul/hanja.c
@@ -338,15 +338,22 @@ hanja_list_new(const char *key)
HanjaList *list;
list = malloc(sizeof(*list));
- if (list != NULL) {
- list->key = strdup(key);
- list->len = 0;
- list->alloc = 1;
- list->items = malloc(list->alloc * sizeof(list->items[0]));
- if (list->items == NULL) {
- free(list);
- list = NULL;
- }
+ if (list == NULL)
+ return NULL;
+
+ list->key = strdup(key);
+ if (list->key == NULL) {
+ free(list);
+ return NULL;
+ }
+
+ list->len = 0;
+ list->alloc = 1;
+ list->items = malloc(list->alloc * sizeof(list->items[0]));
+ if (list->items == NULL) {
+ free(list->key);
+ free(list);
+ return NULL;
}
return list;