allow NULL argument for GNUNET_i2s()
authorChristian Grothoff <christian@grothoff.org>
Sun, 22 Jan 2017 11:23:08 +0000 (12:23 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sun, 22 Jan 2017 11:23:08 +0000 (12:23 +0100)
src/util/common_logging.c

index dad5d3776d762bd6e5386f8a59ec1a16302890bf..1da40675373731a41b3491da9709246291ecd034 100644 (file)
@@ -1209,8 +1209,11 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid)
   static char buf[256];
   char *ret;
 
+  if (NULL == pid)
+    return "NULL";
   ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid->public_key);
-  strcpy (buf, ret);
+  strcpy (buf,
+          ret);
   GNUNET_free (ret);
   buf[4] = '\0';
   return buf;
@@ -1234,8 +1237,11 @@ GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid)
   static char buf[256];
   char *ret;
 
+  if (NULL == pid)
+    return "NULL";
   ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid->public_key);
-  strcpy (buf, ret);
+  strcpy (buf,
+          ret);
   GNUNET_free (ret);
   buf[4] = '\0';
   return buf;