NewsEntries /110405Wrestool

For the last time - Why wrestool uses up all your RAM

What is wrestool?
wrestool is a resource extractor used in GNOME's thumbnailer. So when you view a Win-executable, it's icon has probably been extracted by wrestool. Now there are many people who had issues with this small program, namely that it started to use up all your RAM and grinds your system to a halt.

The reason for this behaviour can be found rather quickly. Though - without wanting to debate xmalloc - it makes me want to rip my hair out. Take a look at the following lines pulled from the wrestool/main.c file.


                /* get file size */
                fi.name = argv[c];
                fi.total_size = file_size(fi.name);
[...]
                /* open file */
                fi.file = fopen(fi.name, "rb");
[...]
                /* read all of file */
                fi.memory = xmalloc(fi.total_size);
                if (fread(fi.memory, fi.total_size, 1, fi.file) != 1) {

..... I am at a loss for words. And I thought using mmap was lazy.

dth? April 05, 2011, at 01:46 UTC