From 26778d3989b4031882d15e64d3a34ae27d57f59f Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:15:03 +0000 Subject: Sun, Apr 28, 2024, 3:15 PM -07:00 --- wk5/pset/speller/dictionary.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'wk5/pset') diff --git a/wk5/pset/speller/dictionary.c b/wk5/pset/speller/dictionary.c index c3111ea..929a93c 100644 --- a/wk5/pset/speller/dictionary.c +++ b/wk5/pset/speller/dictionary.c @@ -54,7 +54,12 @@ bool load(const char *dictionary) char word[LENGTH + 1]; while(fscanf(source, "%s", word) != "E0F") { - malloc(sizefo(node)); + char *ptr = malloc(sizefo(node)); + if (ptr == NULL) + { + fclose(source); + return false; + } } /* @@ -72,6 +77,7 @@ bool load(const char *dictionary) // Close the dictionary file fclose(source); + return true; } // Returns number of words in dictionary if loaded, else 0 if not yet loaded -- cgit v1.2.3