[Secure Coding] master: C++: Mention front(), back() and data() member functions of vectors (7db67ea)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Repository : http://git.fedorahosted.org/git/?p=secure-coding.git

On branch  : master

>---------------------------------------------------------------

commit 7db67ea9b35a0cb04a0b68048802950775558579
Author: Florian Weimer <fweimer@xxxxxxxxxx>
Date:   Thu Sep 19 15:15:28 2013 +0200

    C++: Mention front(), back() and data() member functions of vectors


>---------------------------------------------------------------

 defensive-coding/en-US/CXX-Std.xml |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/defensive-coding/en-US/CXX-Std.xml b/defensive-coding/en-US/CXX-Std.xml
index 56e1ad0..155f70c 100644
--- a/defensive-coding/en-US/CXX-Std.xml
+++ b/defensive-coding/en-US/CXX-Std.xml
@@ -163,6 +163,15 @@
       <literal>operator[](size_type)</literal>, even though it is
       slightly more verbose.
     </para>
+    <para>
+      The <literal>front()</literal> and <literal>back()</literal>
+      member functions are undefined if a vector object is empty.  You
+      can use <literal>vec.at(0)</literal> and
+      <literal>vec.at(vec.size() - 1)</literal> as checked
+      replacements.  For an empty vector, <literal>data()</literal> is
+      defined; it returns an arbitrary pointer, but not necessarily
+      the NULL pointer.
+    </para>
   </section>
   <section id="sect-Defensive_Coding-CXX-Std-Iterators">
     <title>Iterators</title>

--
security mailing list
security@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/security





[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Coolkey]

  Powered by Linux