aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2017-09-11 17:14:21 +0200
committerAndreas Schneider <asn@cryptomilk.org>2017-09-11 17:14:21 +0200
commit72cf2e3ae24b17e55b39831c2b02f26a0ca168a2 (patch)
treedc0afcd631adb12e30c828943e52b9a52b6df2af
parent164cee66ee0e60b53b331323a62a0bbe0060060b (diff)
downloadlibssh-72cf2e3ae24b17e55b39831c2b02f26a0ca168a2.tar.gz
libssh-72cf2e3ae24b17e55b39831c2b02f26a0ca168a2.tar.xz
libssh-72cf2e3ae24b17e55b39831c2b02f26a0ca168a2.zip
README.Coding: Add section about pointers
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--README.CodingStyle21
1 files changed, 21 insertions, 0 deletions
diff --git a/README.CodingStyle b/README.CodingStyle
index badd16f3..11acd8dc 100644
--- a/README.CodingStyle
+++ b/README.CodingStyle
@@ -287,6 +287,27 @@ Good Examples:
return rc;
}
+Initialize pointers
+-------------------
+
+All pointer variables MUST be initialized to NULL. History has
+demonstrated that uninitialized pointer variables have lead to various
+bugs and security issues.
+
+Pointers MUST be initialized even if the assignment directly follows
+the declaration, like pointer2 in the example below, because the
+instructions sequence may change over time.
+
+Good Example:
+
+ char *pointer1 = NULL;
+ char *pointer2 = NULL;
+
+ pointer2 = some_func2();
+
+ ...
+
+ pointer1 = some_func1();
Typedefs
---------