arp242 / find-cursor

Highlight the cursor position in X11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NULL pointer passed to fprintf

bill-auger opened this issue · comments

this causes the build to fail with -Werror

find-cursor.c: In function ‘draw’:
find-cursor.c:152:3: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  152 |   fprintf(stderr, "%s: cannot connect to X server %s\n", name, display_name);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'display_name' will always be NULL on line 152 - this is the correction:

	if (!display_name) {
		fprintf(stderr, "%s: cannot connect to X server\n", name);

Also reported on pull request #11

Thanks @maramon and @bill-auger; I commented on that PR and after that I just, well, forgot :-/

I changed the error message and merged. Thanks both!