]> git.pond.sub.org Git - empserver/commitdiff
Validate explore's third argument earlier
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 18 Jul 2008 22:15:46 +0000 (18:15 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 21 Jul 2008 12:13:40 +0000 (08:13 -0400)
The old code checked a bunch of other things first, which made it hard
to see that the value of onearg() was checked properly.

src/lib/commands/expl.c

index 4ed6590c9071b76be3e8e2cefbfe26e3dfa213d6..f3ce7bbc0aa72291bf135e1d7b505c2a027c8762 100644 (file)
@@ -110,6 +110,8 @@ explore(void)
     sprintf(prompt, "Number of %s to explore with? (max %d) ",
            ip->i_name, amt_src);
     amount = onearg(player->argp[3], prompt);
+    if (amount <= 0)
+       return RET_SYN;
     if (!check_sect_ok(&sect))
        return RET_FAIL;
     if (amount > amt_src) {
@@ -125,8 +127,6 @@ explore(void)
     if (!check_sect_ok(&sect))
        return RET_FAIL;
 
-    if (amount <= 0)
-       return RET_SYN;
     weight = (double)amount * ip->i_lbs;
     /* remove commodities from source sector */
     getsect(x, y, &start);