From 60329bef10f114dac7b9a01d9cd83d6ed25e97ac Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 5 Oct 2010 09:32:46 +0200 Subject: Do complete error checking in the minimal examples --- documentation/cxx/hybrid/guide/index.xhtml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'documentation') diff --git a/documentation/cxx/hybrid/guide/index.xhtml b/documentation/cxx/hybrid/guide/index.xhtml index 460e3b2..39d7e9b 100644 --- a/documentation/cxx/hybrid/guide/index.xhtml +++ b/documentation/cxx/hybrid/guide/index.xhtml @@ -1153,11 +1153,36 @@ main (int argc, char* argv[]) // Change the greeting phrase. // - h->greeting (strdupx ("Hi")); + char* str = strdupx ("Hi"); + + if (str == 0) + { + fprintf (stderr, "error: no memory\n"); + delete h; + return 1; + } + + h->greeting (str); // Add another entry to the name sequence. // - h->name ().push_back (strdupx ("mars")); + str = strdupx ("mars"); + + if (str == 0) + { + fprintf (stderr, "error: no memory\n"); + delete h; + return 1; + } + + if (h->name ().push_back (str) != 0) + { + // The sequence has already freed str. + // + fprintf (stderr, "error: no memory\n"); + delete h; + return 1; + } // Serialize. // -- cgit v1.1