stolk/imcat

Segfault

TheChymera opened this issue · 6 comments

I just compiled your software and I get a segmentation fault when trying to open the example images. Can you help me out?

chymera@bartholin ~/src $ git clone git@github.com:stolk/imcat.git
Cloning into 'imcat'...
remote: Enumerating objects: 69, done.
remote: Total 69 (delta 0), reused 0 (delta 0), pack-reused 69
Receiving objects: 100% (69/69), 587.25 KiB | 1.55 MiB/s, done.
Resolving deltas: 100% (30/30), done.
chymera@bartholin ~/src $ cd imcat/
chymera@bartholin ~/src/imcat $ git rev-parse HEAD
ee82fdbbc3789fd13aad0365b0549bb33ade2f4d
chymera@bartholin ~/src/imcat $ make
cc -std=c99 -Wall -g -o imcat imcat.c -lm
imcat.c: In function ‘get_terminal_size’:
imcat.c:48:12: warning: implicit declaration of function ‘popen’; did you mean ‘fopen’? [-Wimplicit-function-declaration]
   48 |  FILE* f = popen( "stty size", "r" );
      |            ^~~~~
      |            fopen
imcat.c:48:12: warning: initialization of ‘FILE *’ {aka ‘struct _IO_FILE *’} from ‘
int’ makes pointer from integer without a cast [-Wint-conversion]
imcat.c:56:2: warning: implicit declaration of function ‘pclose’; did you mean ‘fclose’? [-Wimplicit-function-declaration]
   56 |  pclose( f );
      |  ^~~~~~
      |  fclose
chymera@bartholin ~/src/imcat $ ./imcat images/imcat_tiger.png 
Segmentation fault (core dumped)
chymera@bartholin ~/src/imcat $ ./imcat images/sampledesktop.png 
Segmentation fault (core dumped)

I was able to reproduce this on two different machines. So something is either broken in the package code, or some requirement which I am not meeting is not specified.

stolk commented

Thanks, can you attach the png file you used?

Also: What if you execute imcat without arguments? Does it crash too?

I will also look into the popen issue.

What does cc --version give you?

stolk commented

What system is this? BSD perhaps?

On my Ubuntu Linux, popen is defined in <stdio.h> which is included by imcat.c

$ man popen

 #include <stdio.h>

 FILE *popen(const char *command, const char *type);
stolk commented

Seems to be this issue:
https://stackoverflow.com/a/5468444/301166
I will commit a fix.

stolk commented

I think I fixed it. Please do git pull and try again. Thanks!

218d975

Amazing, that did it, thank you :)