Changeset dfc416e in rtems-libbsd


Ignore:
Timestamp:
Oct 18, 2013, 9:15:53 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, afaeccc05a556f6aa25ba044a7e49d6aa634a59e, freebsd-9.3, master
Children:
d02c998
Parents:
2a08d43
git-author:
Sebastian Huber <sebastian.huber@…> (10/18/13 09:15:53)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/31/13 12:18:48)
Message:

ROUTE(8): Free dynamic memory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sbin/route/route.c

    r2a08d43 rdfc416e  
    292292        if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
    293293                err(EX_OSERR, "route-sysctl-estimate");
    294         if ((buf = malloc(needed)) == NULL)
     294        if ((buf = malloc(needed)) == NULL && needed != 0)
    295295                errx(EX_OSERR, "malloc failed");
    296296        if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
     
    347347                }
    348348        }
     349        free(buf);
    349350}
    350351
     
    11941195        if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
    11951196                err(EX_OSERR, "route-sysctl-estimate");
    1196         if ((buf = malloc(needed)) == NULL)
     1197        if ((buf = malloc(needed)) == NULL && needed != 0)
    11971198                errx(EX_OSERR, "malloc failed");
    11981199        if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
     
    12101211                print_rtmsg(c, rtm, rtm->rtm_msglen);
    12111212        }
     1213        free(buf);
    12121214}
    12131215
Note: See TracChangeset for help on using the changeset viewer.