X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=libctf%2Fctf-decl.c;h=5dcf60ab08bdbac42b3dc459ac89fb48c4fa6905;hb=refs%2Fheads%2Fconcurrent-displaced-stepping-2020-04-01;hp=c85982e4a3f16ea93c1f10a02296d16334de4eab;hpb=316afdb130346e44622229793d1fb8d391059f8d;p=deliverable%2Fbinutils-gdb.git diff --git a/libctf/ctf-decl.c b/libctf/ctf-decl.c index c85982e4a3..5dcf60ab08 100644 --- a/libctf/ctf-decl.c +++ b/libctf/ctf-decl.c @@ -1,5 +1,5 @@ /* C declarator syntax glue. - Copyright (C) 2019 Free Software Foundation, Inc. + Copyright (C) 2019-2020 Free Software Foundation, Inc. This file is part of libctf. @@ -65,7 +65,7 @@ ctf_decl_fini (ctf_decl_t *cd) for (cdp = ctf_list_next (&cd->cd_nodes[i]); cdp != NULL; cdp = ndp) { ndp = ctf_list_next (cdp); - ctf_free (cdp); + free (cdp); } } } @@ -132,7 +132,7 @@ ctf_decl_push (ctf_decl_t *cd, ctf_file_t *fp, ctf_id_t type) prec = CTF_PREC_BASE; } - if ((cdp = ctf_alloc (sizeof (ctf_decl_node_t))) == NULL) + if ((cdp = malloc (sizeof (ctf_decl_node_t))) == NULL) { cd->cd_err = EAGAIN; return; @@ -176,10 +176,14 @@ void ctf_decl_sprintf (ctf_decl_t *cd, const char *format, ...) va_end (ap); if (n > 0) - cd->cd_buf = ctf_str_append (cd->cd_buf, str); + { + char *newbuf; + if ((newbuf = ctf_str_append (cd->cd_buf, str)) != NULL) + cd->cd_buf = newbuf; + } /* Sticky error condition. */ - if (n < 0) + if (n < 0 || cd->cd_buf == NULL) { free (cd->cd_buf); cd->cd_buf = NULL;