firmware-utils: fix segfault introduced by v2 changes
authorJohn Crispin <john@openwrt.org>
Tue, 6 Aug 2013 14:32:50 +0000 (14:32 +0000)
committerJohn Crispin <john@openwrt.org>
Tue, 6 Aug 2013 14:32:50 +0000 (14:32 +0000)
Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>
SVN-Revision: 37724

tools/firmware-utils/src/mktplinkfw.c

index 05e40c5daf374a46a2eae2aa8adad159aef0b2aa..f6fdff49433bc394f6fe88e458b7232b4e779ff6 100644 (file)
@@ -811,7 +811,7 @@ static int build_fw(void)
        int ret = EXIT_FAILURE;
        int writelen = 0;
        int hdr_len;
-       if (board->hdr_version == HEADER_VERSION_V2)
+       if (board && board->hdr_version == HEADER_VERSION_V2)
                hdr_len = sizeof(struct fw_header_v2);
        else
                hdr_len = sizeof(struct fw_header);
@@ -854,7 +854,7 @@ static int build_fw(void)
        if (!strip_padding)
                writelen = buflen;
 
-       if (board->hdr_version == HEADER_VERSION_V2)
+       if (board && board->hdr_version == HEADER_VERSION_V2)
                fill_header_v2(buf, writelen);
        else
                fill_header(buf, writelen);