Discussion:
[PATCH] getprogname: fix port to IRIX
Paul Eggert
2017-01-09 06:14:05 UTC
Permalink
* lib/getprogname.c (getprogname) [__sgi]:
Don't dump core if malloc returns NULL.
---
ChangeLog | 4 ++++
lib/getprogname.c | 7 +++++--
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 79475df..0d60422 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2017-01-08 Paul Eggert <***@cs.ucla.edu>

+ getprogname: fix port to IRIX
+ * lib/getprogname.c (getprogname) [__sgi]:
+ Don't dump core if malloc returns NULL.
+
dfa: fix reallocation bug when matching newlines
Problem reported for sed by S. Gilles (Bug#25390).
* lib/dfa.c (realloc_trans_if_necessary): Move earlier.
diff --git a/lib/getprogname.c b/lib/getprogname.c
index 729f01e..abc03ec 100644
--- a/lib/getprogname.c
+++ b/lib/getprogname.c
@@ -169,8 +169,11 @@ getprogname (void)
char *namenul = memchr (name, '\0', namesize);
size_t namelen = namenul ? namenul - name : namesize;
char *namecopy = malloc (namelen + 1);
- namecopy[namelen] = 0;
- return memcpy (namecopy, name, namelen);
+ if (namecopy)
+ {
+ namecopy[namelen] = 0;
+ return memcpy (namecopy, name, namelen);
+ }
}
}
return NULL;
--
2.9.3
Paul Eggert
2017-11-11 20:17:39 UTC
Permalink
Thanks for fixing that longstanding typo. But wow, IRIX? SGI itself stopped
supporting IRIX in 2013.

Do you have a computer museum in your attic? In the late 1980s I unwisely
accepted an old PDP-11 that rested in my garage until I threw it away. I had
been thinking of running 7th Edition Unix on it, just for fun. But it was a big
and heavy clunker and I never even powered it on.

Loading...