Fix
This commit is contained in:
parent
2769651fe1
commit
9f9d7a1925
@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
printf("Chunk size is:%d\n", chunks[i]->length);
|
printf("Chunk size is:%d\n", chunks[i]->length);
|
||||||
}
|
}
|
||||||
write_png_chunks(path, chunks);
|
// write_png_chunks(path, chunks);
|
||||||
destroy_chunks(chunks);
|
destroy_chunks(chunks);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
@ -123,10 +123,7 @@ png_chunk **get_png_chunks(char *buffer) {
|
|||||||
|
|
||||||
int get_number_of_chunks(png_chunk **chunks) {
|
int get_number_of_chunks(png_chunk **chunks) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (true) {
|
while (memcmp(chunks[i]->type, "IEND", 4) != 0) {
|
||||||
if (memcmp(chunks[i]->type, "IEND", 4) == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
@ -141,7 +138,8 @@ void xor_data(png_chunk *chunk) {
|
|||||||
|
|
||||||
|
|
||||||
void destroy_chunks(png_chunk **chunks) {
|
void destroy_chunks(png_chunk **chunks) {
|
||||||
for (int i = 0; get_number_of_chunks(chunks); i++) {
|
unsigned int size = get_number_of_chunks(chunks);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
free(chunks[i]->data);
|
free(chunks[i]->data);
|
||||||
free(chunks[i]);
|
free(chunks[i]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user