diff --git a/sk1/compressor.c b/sk1/compressor.c index 8db8eff..3429d0d 100644 --- a/sk1/compressor.c +++ b/sk1/compressor.c @@ -133,7 +133,9 @@ void storeCodes(struct MinHeapNode* root, char** codes, char* currentCode, int t } if (!(root->left) && !(root->right)) { currentCode[top] = '\0'; + if (root->data < 256) { // Ensure data is within bounds codes[root->data] = strdup(currentCode); + } } } // Compress the input file using Huffman Coding