+2007-11-03 Bruno Haible <bruno@clisp.org>
+
+ Fix out-of-memory handling of vasnprintf.
+ * printf-parse.c: Include <errno.h>.
+ (PRINTF_PARSE): When failing, set errno to EINVAL or ENOMEM.
+ * vasnprintf.c (VASNPRINTF): When PRINTF_PARSE fails, assume errno is
+ already set.
+
2007-11-01 Bruno Haible <bruno@clisp.org>
* libgnuintl.h.in (LIBINTL_VERSION): Bump to 0.17.
/* malloc(), realloc(), free(). */
#include <stdlib.h>
+/* errno. */
+#include <errno.h>
+
/* Checked size_t computations. */
#include "xsize.h"
d->dir = (DIRECTIVE *) malloc (d_allocated * sizeof (DIRECTIVE));
if (d->dir == NULL)
/* Out of memory. */
- return -1;
+ goto out_of_memory_1;
a->count = 0;
a_allocated = 0;
memory_size = xtimes (a_allocated, sizeof (argument)); \
if (size_overflow_p (memory_size)) \
/* Overflow, would lead to out of memory. */ \
- goto error; \
+ goto out_of_memory; \
memory = (argument *) (a->arg \
? realloc (a->arg, memory_size) \
: malloc (memory_size)); \
if (memory == NULL) \
/* Out of memory. */ \
- goto error; \
+ goto out_of_memory; \
a->arg = memory; \
} \
while (a->count <= n) \
memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
if (size_overflow_p (memory_size))
/* Overflow, would lead to out of memory. */
- goto error;
+ goto out_of_memory;
memory = (DIRECTIVE *) realloc (d->dir, memory_size);
if (memory == NULL)
/* Out of memory. */
- goto error;
+ goto out_of_memory;
d->dir = memory;
}
}
free (a->arg);
if (d->dir)
free (d->dir);
+ errno = EINVAL;
+ return -1;
+
+out_of_memory:
+ if (a->arg)
+ free (a->arg);
+ if (d->dir)
+ free (d->dir);
+out_of_memory_1:
+ errno = ENOMEM;
return -1;
}
arguments a;
if (PRINTF_PARSE (format, &d, &a) < 0)
- {
- errno = EINVAL;
- return NULL;
- }
+ /* errno is already set. */
+ return NULL;
#define CLEANUP() \
free (d.dir); \
+2007-11-03 Bruno Haible <bruno@clisp.org>
+
+ Fix out-of-memory handling of vasnprintf.
+ * printf-parse.c: Include <errno.h>.
+ (PRINTF_PARSE): When failing, set errno to EINVAL or ENOMEM.
+ * vasnprintf.c (VASNPRINTF): When PRINTF_PARSE fails, assume errno is
+ already set.
+
2007-10-21 Bruno Haible <bruno@clisp.org>
* printf-parse.c: Don't assume <stdint.h> exists in IN_LIBASPRINTF
/* malloc(), realloc(), free(). */
#include <stdlib.h>
+/* errno. */
+#include <errno.h>
+
/* Checked size_t computations. */
#include "xsize.h"
d->dir = (DIRECTIVE *) malloc (d_allocated * sizeof (DIRECTIVE));
if (d->dir == NULL)
/* Out of memory. */
- return -1;
+ goto out_of_memory_1;
a->count = 0;
a_allocated = 0;
memory_size = xtimes (a_allocated, sizeof (argument)); \
if (size_overflow_p (memory_size)) \
/* Overflow, would lead to out of memory. */ \
- goto error; \
+ goto out_of_memory; \
memory = (argument *) (a->arg \
? realloc (a->arg, memory_size) \
: malloc (memory_size)); \
if (memory == NULL) \
/* Out of memory. */ \
- goto error; \
+ goto out_of_memory; \
a->arg = memory; \
} \
while (a->count <= n) \
memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
if (size_overflow_p (memory_size))
/* Overflow, would lead to out of memory. */
- goto error;
+ goto out_of_memory;
memory = (DIRECTIVE *) realloc (d->dir, memory_size);
if (memory == NULL)
/* Out of memory. */
- goto error;
+ goto out_of_memory;
d->dir = memory;
}
}
free (a->arg);
if (d->dir)
free (d->dir);
+ errno = EINVAL;
+ return -1;
+
+out_of_memory:
+ if (a->arg)
+ free (a->arg);
+ if (d->dir)
+ free (d->dir);
+out_of_memory_1:
+ errno = ENOMEM;
return -1;
}
arguments a;
if (PRINTF_PARSE (format, &d, &a) < 0)
- {
- errno = EINVAL;
- return NULL;
- }
+ /* errno is already set. */
+ return NULL;
#define CLEANUP() \
free (d.dir); \