]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
dupstr() should cope with being passed NULL
authorJacob Nevins <jacobn@chiark.greenend.org.uk>
Fri, 29 Aug 2003 22:14:04 +0000 (22:14 +0000)
committerJacob Nevins <jacobn@chiark.greenend.org.uk>
Fri, 29 Aug 2003 22:14:04 +0000 (22:14 +0000)
[originally from svn r3429]

misc.c

diff --git a/misc.c b/misc.c
index 3fea3746f8d1121c8455e6c9cca4f8bb6048d15a..78d829a9b4ecfb8cafdbc648e73d12fd499ef9c9 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;
 }