diff options
author | Darren Tucker <dtucker@zip.com.au> | 2007-02-19 22:56:55 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2007-02-19 22:56:55 +1100 |
commit | 89ee69e3c639b55b7577ba8fde66450446f74ea4 (patch) | |
tree | 36bd6f19e797181541d39013081a782d54e27358 /openbsd-compat/getrrsetbyname.c | |
parent | 53ced25d6185b4a02305e9d4bf648113155dde07 (diff) |
- (dtucker) [openbsd-compat/getrrsetbyname.c] Don't attempt to calloc
an array for signatures when there are none since "calloc(0, n) returns
NULL on some platforms (eg Tru64), which is explicitly permitted by
POSIX. Diagnosis and patch by svallet genoscope.cns.fr.
Diffstat (limited to 'openbsd-compat/getrrsetbyname.c')
-rw-r--r-- | openbsd-compat/getrrsetbyname.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c index 6c86e02c..07231d00 100644 --- a/openbsd-compat/getrrsetbyname.c +++ b/openbsd-compat/getrrsetbyname.c @@ -303,10 +303,12 @@ getrrsetbyname(const char *hostname, unsigned int rdclass, } /* allocate memory for signatures */ - rrset->rri_sigs = calloc(rrset->rri_nsigs, sizeof(struct rdatainfo)); - if (rrset->rri_sigs == NULL) { - result = ERRSET_NOMEMORY; - goto fail; + if (rrset->rri_nsigs > 0) { + rrset->rri_sigs = calloc(rrset->rri_nsigs, sizeof(struct rdatainfo)); + if (rrset->rri_sigs == NULL) { + result = ERRSET_NOMEMORY; + goto fail; + } } /* copy answers & signatures */ |