stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r637080 - /stdcxx/branches/4.2.x/util/gencat.cpp
Date Fri, 14 Mar 2008 12:36:24 GMT
Author: faridz
Date: Fri Mar 14 05:36:21 2008
New Revision: 637080

URL: http://svn.apache.org/viewvc?rev=637080&view=rev
Log:
2008-03-14 Farid Zaripov <farid_zaripov@epam.com>

	Merge r637079 from trunk with a fix for STDCXX-752
	* util/gencat.cpp: Asserted precondition to silence HP aCC
	warning #20200-D: Potential null pointer dereference.

Modified:
    stdcxx/branches/4.2.x/util/gencat.cpp

Modified: stdcxx/branches/4.2.x/util/gencat.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/gencat.cpp?rev=637080&r1=637079&r2=637080&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/util/gencat.cpp (original)
+++ stdcxx/branches/4.2.x/util/gencat.cpp Fri Mar 14 05:36:21 2008
@@ -28,6 +28,7 @@
 #include <cstdio>    // for printf()
 #include <cstring>   // for strcmp(), strrchr()
 #include <cstddef>   // for size_t
+#include <cassert>   // for assert()
 
 #include <string>
 
@@ -63,11 +64,16 @@
 
 int main (int argc, char *argv[])
 {
-    const char* exe_name = std::strrchr (argv [0], SLASH);
-    if (exe_name)
-        ++exe_name;
-    else
-        exe_name = argv [0];
+    const char* exe_name = "gencat";
+
+    if (argv [0]) {
+        if (const char* slash = std::strrchr (argv [0], SLASH))
+            exe_name = slash + 1;
+        else
+            exe_name = argv [0];
+    }
+
+    assert (exe_name);
 
     if (1 == argc) {
         std::printf (usage_text, exe_name);



Mime
View raw message