Skip to content

Commit

Permalink
Examples: Do not ignore return value of scanf
Browse files Browse the repository at this point in the history
  • Loading branch information
sanssecours committed Oct 10, 2018
1 parent 2dae8bf commit 3d420a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/kdbset.c
Expand Up @@ -9,6 +9,7 @@
#include <kdb.h> #include <kdb.h>


#include <stdio.h> #include <stdio.h>
#include <stdlib.h>


typedef enum typedef enum
{ {
Expand All @@ -21,7 +22,11 @@ int showElektraErrorDialog (Key * parentKey, Key * problemKey)
{ {
printf ("dialog for %s and %s\n", keyName (parentKey), keyName (problemKey)); printf ("dialog for %s and %s\n", keyName (parentKey), keyName (problemKey));
int a; int a;
scanf ("%d", &a); if (scanf ("%d", &a) != 1)
{
fprintf (stderr, "Unable to convert input to integer number");
return EXIT_FAILURE;
}
return a; return a;
} }


Expand Down

0 comments on commit 3d420a5

Please sign in to comment.