Permalink
Browse files

Examples: Do not ignore return value of `scanf`

  • Loading branch information...
sanssecours committed Oct 10, 2018
1 parent 2dae8bf commit 3d420a53dcc744f538f13811004f73293a285290
Showing with 6 additions and 1 deletion.
  1. +6 −1 examples/kdbset.c
@@ -9,6 +9,7 @@
#include <kdb.h>
#include <stdio.h>
#include <stdlib.h>
typedef enum
{
@@ -21,7 +22,11 @@ int showElektraErrorDialog (Key * parentKey, Key * problemKey)
{
printf ("dialog for %s and %s\n", keyName (parentKey), keyName (problemKey));
int a;
scanf ("%d", &a);
if (scanf ("%d", &a) != 1)
{
fprintf (stderr, "Unable to convert input to integer number");
return EXIT_FAILURE;
}
return a;
}

0 comments on commit 3d420a5

Please sign in to comment.