]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
rr.c: (ldns_rr_push_rd_field) Check result of XREALLOC and return false on
authorErik Rozendaal <erik@NLnetLabs.nl>
Wed, 15 Dec 2004 08:50:30 +0000 (08:50 +0000)
committerErik Rozendaal <erik@NLnetLabs.nl>
Wed, 15 Dec 2004 08:50:30 +0000 (08:50 +0000)
failure.

ldns/rr.h
rr.c

index 0969af984ff781f81877909559314816ee0517e3..de2a29ebb65bfdaf33399b201b8079b5886b2f11 100644 (file)
--- a/ldns/rr.h
+++ b/ldns/rr.h
@@ -14,8 +14,9 @@
 #ifndef _LDNS_RR_H
 #define _LDNS_RR_H
 
-#include "ldns/rdata.h"
-#include "ldns/rr.h"
+#include <ldns/common.h>
+#include <ldns/rdata.h>
+#include <ldns/rr.h>
 
 /* the different RR types */
 /**  a host address */
@@ -164,7 +165,7 @@ void ldns_rr_set_owner(t_rr *, uint8_t *);
 void ldns_rr_set_ttl(t_rr *, uint16_t);
 void ldns_rr_set_rd_count(t_rr *, uint16_t);
 void ldns_rr_set_class(t_rr *, t_class);
-void ldns_rr_push_rd_field(t_rr *, t_rdata_field *);
+bool ldns_rr_push_rd_field(t_rr *, t_rdata_field *);
 uint8_t *ldns_rr_owner(t_rr *);
 uint8_t ldns_rr_ttl(t_rr *);
 uint16_t ldns_rr_rd_count(t_rr *);
diff --git a/rr.c b/rr.c
index 454b0b480f49dbea4d7a028d66e64df40943d2fb..a9b9364e8d934c0c2d19389d394609cbd46eb393 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -73,18 +73,23 @@ ldns_rr_set_class(t_rr *rr, t_class klass)
  * set rd_field member in the rr, it will be 
  * placed in the next available spot
  */
-void
+bool
 ldns_rr_push_rd_field(t_rr *rr, t_rdata_field *f)
 {
        uint16_t rd_count;
-
+       t_rdata_field **rdata_fields;
+       
        rd_count = ldns_rr_rd_count(rr);
        
        /* grow the array */
-       rr->_rdata_fields = XREALLOC(
+       rdata_fields = XREALLOC(
                rr->_rdata_fields, t_rdata_field *, rd_count + 1);
-
+       if (!rdata_fields) {
+               return false;
+       }
+       
        /* add the new member */
+       rr->_rdata_fields = rdata_fields;
        rr->_rdata_fields[rd_count] = f;
 
        ldns_rr_set_rd_count(rr, rd_count + 1);