dupstr() should cope with being passed NULL
authorjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Fri, 29 Aug 2003 22:14:04 +0000 (22:14 +0000)
committerjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Fri, 29 Aug 2003 22:14:04 +0000 (22:14 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@3429 cda61777-01e9-0310-a592-d414129be87e

misc.c

diff --git a/misc.c b/misc.c
index 3fea374..78d829a 100644 (file)
--- a/misc.c
+++ b/misc.c
 
 char *dupstr(const char *s)
 {
-    int len = strlen(s);
-    char *p = snewn(len + 1, char);
-    strcpy(p, s);
+    char *p = NULL;
+    if (s) {
+        int len = strlen(s);
+        p = snewn(len + 1, char);
+        strcpy(p, s);
+    }
     return p;
 }