]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: avoid endless loop in sound play command
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 30 Dec 2022 23:49:10 +0000 (00:49 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Wed, 4 Jan 2023 12:17:42 +0000 (13:17 +0100)
A parameter starting with a hyphen leads to an endless loop in the sound
play command.

Leave it to dectoul() to handle the hyphen. It will return 0 for a negative
number.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/sound.c

index cef71be5e34ec15e4bf438c6df36c8a21035a99c..0b7f9599716b29a6d1f9d68fedaafe2caae648d4 100644 (file)
@@ -48,12 +48,12 @@ static int do_play(struct cmd_tbl *cmdtp, int flag, int argc,
        ++argv;
        while (argc || first) {
                first = false;
-               if (argc && *argv[0] != '-') {
+               if (argc) {
                        msec = dectoul(argv[0], NULL);
                        --argc;
                        ++argv;
                }
-               if (argc && *argv[0] != '-') {
+               if (argc) {
                        freq = dectoul(argv[0], NULL);
                        --argc;
                        ++argv;