bigcode-project / starcoder.cpp

C++ implementation for 💫StarCoder
445 stars 36 forks source link

fixed potential memory leak, deleted unnecessary semicolon #34

Open mendax0110 opened 1 year ago

mendax0110 commented 1 year ago

Pull Request Summary:

This pull request addresses a potential memory leak in the load_model function by ensuring that the dynamically allocated memory for 'model' is properly deallocated before returning NULL in case of a model loading failure. Additionally, it includes changes to the convert-hf-to-ggml.py script to improve its readability and consistency.

Changes Made:

Explanation:

The load_model function previously allocated memory for 'model' using the new operator but didn't release it in case the model loading failed, potentially causing a memory leak. To address this issue, I added a delete model; statement before returning NULL when the loading fails.

In the convert-hf-to-ggml.py script, I removed a few semicolons that were not required for proper code execution. This change enhances the code's readability and maintains consistency with Python's coding style.