mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
fix LGTM - limit malloc range
This commit is contained in:
parent
619620d65d
commit
6710df7ec3
@ -50,9 +50,13 @@ void PrintSortedPermutations(char *str)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
unsigned int n; // size of string
|
int n; // size of string
|
||||||
scanf("%u\n", &n);
|
scanf("%d\n", &n);
|
||||||
|
if (n <= 0 || n >= 1000)
|
||||||
|
{
|
||||||
|
perror("Input number out of range: >0 and <1000\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
char *str = (char *)malloc(n * sizeof(char));
|
char *str = (char *)malloc(n * sizeof(char));
|
||||||
scanf("%s", str);
|
scanf("%s", str);
|
||||||
PrintSortedPermutations(str);
|
PrintSortedPermutations(str);
|
||||||
|
Loading…
Reference in New Issue
Block a user