diff options
Diffstat (limited to 'manual/filesys.texi')
-rw-r--r-- | manual/filesys.texi | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/manual/filesys.texi b/manual/filesys.texi index e715ec7ad1..a74f32d9fe 100644 --- a/manual/filesys.texi +++ b/manual/filesys.texi @@ -1141,16 +1141,19 @@ char * readlink_malloc (const char *filename) @{ int size = 100; + char *buffer = NULL; while (1) @{ - char *buffer = (char *) xmalloc (size); + buffer = (char *) xrealloc (buffer, size); int nchars = readlink (filename, buffer, size); if (nchars < 0) - return NULL; + @{ + free (buffer); + return NULL; + @} if (nchars < size) return buffer; - free (buffer); size *= 2; @} @} |