summaryrefslogtreecommitdiff
path: root/rr.c
diff options
context:
space:
mode:
authorWouter Wijngaards <wouter@NLnetLabs.nl>2010-07-27 14:18:54 +0200
committerWouter Wijngaards <wouter@NLnetLabs.nl>2010-07-27 14:18:54 +0200
commitdd6d3c0410700e6bb498ea610e5aa0616f8217b5 (patch)
tree156c476151ba28de5c923007168a1cb6afca3193 /rr.c
parentf5365a33ef96163b394db367b11c7a56fb01943f (diff)
downloadldns-dd6d3c0410700e6bb498ea610e5aa0616f8217b5.tar.gz
Fix ldns_rr_rdf_pop.
Diffstat (limited to 'rr.c')
-rw-r--r--rr.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/rr.c b/rr.c
index 62e879bb..d3160e19 100644
--- a/rr.c
+++ b/rr.c
@@ -732,6 +732,7 @@ ldns_rr_pop_rdf(ldns_rr *rr)
{
size_t rd_count;
ldns_rdf *pop;
+ ldns_rdf** newrd;
rd_count = ldns_rr_rd_count(rr);
@@ -741,9 +742,15 @@ ldns_rr_pop_rdf(ldns_rr *rr)
pop = rr->_rdata_fields[rd_count - 1];
- /* shrink the array */
- rr->_rdata_fields = LDNS_XREALLOC(
- rr->_rdata_fields, ldns_rdf *, rd_count - 1);
+ /* try to shrink the array */
+ if(rd_count > 1) {
+ newrd = LDNS_XREALLOC(
+ rr->_rdata_fields, ldns_rdf *, rd_count - 1);
+ if(newrd)
+ rr->_rdata_fields = newrd;
+ } else {
+ LDNS_FREE(rr->_rdata_fields);
+ }
ldns_rr_set_rd_count(rr, rd_count - 1);
return pop;