fix: realloc pagechunk with non null term chunk

This commit is contained in:
_N3m0 2023-12-30 22:07:50 +01:00
parent 4dbba1feee
commit 4660e36790
2 changed files with 2 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
webpage
out
test.sh
test.c
a.out

3
main.c
View File

@ -50,7 +50,7 @@ size_t save_chunk(char* buffer, size_t itemsize, size_t nitems, void* ignore){
memset(&pageChunk[nbchunck], 0, pageChunkLen - nbchunck);
}
pageChunk[nbchunck] = malloc(bytes);
pageChunk[nbchunck] = malloc(bytes+1);
pageChunk[nbchunck][bytes] = '\0';
strncpy(pageChunk[nbchunck], buffer, bytes);
nbchunck++;
@ -79,7 +79,6 @@ void getPage(void){
void printPage(void){
for (int i=0; i<nbchunck; i++){
printf("%s", pageChunk[i]);
//printf("%d - %p\n", i, pageChunk[i]);
}
}