[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r104477: * lib/allocator.h, lib/carea
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r104477: * lib/allocator.h, lib/careadlinkat.c: Merge from gnulib. |
Date: |
Thu, 02 Jun 2011 01:22:57 -0700 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 104477
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Thu 2011-06-02 01:22:57 -0700
message:
* lib/allocator.h, lib/careadlinkat.c: Merge from gnulib.
modified:
ChangeLog
lib/allocator.h
lib/careadlinkat.c
=== modified file 'ChangeLog'
--- a/ChangeLog 2011-05-31 05:34:40 +0000
+++ b/ChangeLog 2011-06-02 08:22:57 +0000
@@ -1,3 +1,7 @@
+2011-06-02 Paul Eggert <address@hidden>
+
+ * lib/allocator.h, lib/careadlinkat.c: Merge from gnulib.
+
2011-05-30 Paul Eggert <address@hidden>
Use 'inline', not 'INLINE'.
=== modified file 'lib/allocator.h'
--- a/lib/allocator.h 2011-04-09 18:44:05 +0000
+++ b/lib/allocator.h 2011-06-02 08:22:57 +0000
@@ -45,10 +45,11 @@
/* Call FREE to free memory, like 'free'. */
void (*free) (void *);
- /* If nonnull, call DIE if MALLOC or REALLOC fails. DIE should not
- return. DIE can be used by code that detects memory overflow
- while calculating sizes to be passed to MALLOC or REALLOC. */
- void (*die) (void);
+ /* If nonnull, call DIE (SIZE) if MALLOC (SIZE) or REALLOC (...,
+ SIZE) fails. DIE should not return. SIZE should equal SIZE_MAX
+ if size_t overflow was detected while calculating sizes to be
+ passed to MALLOC or REALLOC. */
+ void (*die) (size_t);
};
/* An allocator using the stdlib functions and a null DIE function. */
=== modified file 'lib/careadlinkat.c'
--- a/lib/careadlinkat.c 2011-04-10 16:00:46 +0000
+++ b/lib/careadlinkat.c 2011-06-02 08:22:57 +0000
@@ -135,6 +135,7 @@
if (buf == stack_buf)
{
char *b = (char *) alloc->allocate (link_size);
+ buf_size = link_size;
if (! b)
break;
memcpy (b, buf, link_size);
@@ -158,6 +159,11 @@
buf_size *= 2;
else if (buf_size < buf_size_max)
buf_size = buf_size_max;
+ else if (buf_size_max < SIZE_MAX)
+ {
+ errno = ENAMETOOLONG;
+ return NULL;
+ }
else
break;
buf = (char *) alloc->allocate (buf_size);
@@ -165,7 +171,7 @@
while (buf);
if (alloc->die)
- alloc->die ();
+ alloc->die (buf_size);
errno = ENOMEM;
return NULL;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r104477: * lib/allocator.h, lib/careadlinkat.c: Merge from gnulib.,
Paul Eggert <=