In attempting to use imgtops on both Solaris and Linux (FC6) I encountered segmentation faults, which I eventually traced to the encoders.c module that accelerates run encoding and ASCII 85 encoding. The pure Python version works correctly.
One problem appears to be that calls to "realloc" have the wrong size passed so the buffer actually shrinks. ("outlen = length / 16 + 256" vs "outlen += length / 16 + 256"). However this fix for each realloc call only fixed the segmentation fault for some images.
While trying to understand where the other segmentation fault may come from I came across a use of the "goto" statement, the target of which is the "then" clause of a conditional inside a "while" loop. So the "goto" leaps into rather than out of a loop. At this point I decided to write a version of the run-encoding function that did not depend on this complicated control flow. I have attempted to maintain the original coding style in the modified encoders.c, which is attached.
The new version identifies arbitrarily long actual runs and then emits them as a sequence of encoded runs.
New implementation of RunLengthEncode function