smolorg / smolar

a tiny multidimensional array implementation in C similar to numpy, but only one file.
Apache License 2.0
206 stars 7 forks source link

segfault and memory leak #3

Open AadityaSuri opened 1 month ago

AadityaSuri commented 1 month ago

if (arr->idxs != NULL) { // clean up indices for (int i = 0; i < arr->idxs->count; i++) { free(arr->idxs->indices[i]); } free(arr->idxs->indices); free(arr->idxs); }

this segment in createArrayIndices() causes the program to segfault when any smolar function is run more than once in a loop. can be reproduced if run using gdb main (or main.c executable name) then let it run without breakpoints.

there is memory leakage in smCreate. checked using valgrind

full valgrind log for main.c executable valgrind-out.txt

Maharshi-Pandya commented 1 month ago

thanks for letting me know, will make some changes.