From: wesommer Date: Thu, 3 Sep 1987 02:29:18 +0000 (+0000) Subject: strsave: Kludged up null ptr handling for compat with version in dcm. X-Git-Tag: BETA5-24-88~74 X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/0fed7e9b6e630f1ed29833db4260f8107fa82d02 strsave: Kludged up null ptr handling for compat with version in dcm. Linted. --- diff --git a/lib/strs.c b/lib/strs.c index 86f96c9e..284c1f36 100644 --- a/lib/strs.c +++ b/lib/strs.c @@ -12,6 +12,11 @@ static char *rcsid_strs_c = "$Header$"; #endif lint +#include +#include +#include + +extern char *malloc(), *realloc(); /* * Random string functions which should be in the C library.. @@ -24,8 +29,17 @@ char * strsave(s) char *s; { - register int len = strlen(s) + 1; - register char *p = malloc((u_int)len); + register int len; + register char *p; + /* Kludge for sloppy string semantics */ + if (!s) { + printf("NULL != \"\" !!!!\r\n"); + p = malloc(1); + *p = "\0"; + return p; + } + len = strlen(s) + 1; + p = malloc((u_int)len); if (p) bcopy(s, p, len); return p; }