free (a.arg);
if (PRINTF_FETCHARGS (args, &a) < 0)
- {
- CLEANUP ();
- errno = EINVAL;
- return NULL;
- }
+ goto fail_1_with_EINVAL;
{
size_t buf_neededlength;
if (count == 0)
break;
if (count < 0)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
if (count == 0)
break;
if (count < 0)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
converted, &converted_len);
# endif
if (converted == NULL)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
if (converted != result + length)
{
ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
if (count == 0)
break;
if (count < 0)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
if (count == 0)
break;
if (count < 0)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
converted, &converted_len);
# endif
if (converted == NULL)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
if (converted != result + length)
{
ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
if (count == 0)
break;
if (count < 0)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
if (count == 0)
break;
if (count < 0)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
converted, &converted_len);
# endif
if (converted == NULL)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
if (converted != result + length)
{
ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
/* Found the terminating NUL. */
break;
if (count < 0)
- {
- /* Invalid or incomplete multibyte character. */
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Invalid or incomplete multibyte character. */
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
/* Found the terminating NUL. */
break;
if (count < 0)
- {
- /* Invalid or incomplete multibyte character. */
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Invalid or incomplete multibyte character. */
+ goto fail_with_EILSEQ;
arg_end += count;
characters++;
}
break;
count = local_wcrtomb (cbuf, *arg_end, &state);
if (count < 0)
- {
- /* Cannot convert. */
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Cannot convert. */
+ goto fail_with_EILSEQ;
if (precision < (unsigned int) count)
break;
arg_end++;
break;
count = local_wcrtomb (cbuf, *arg_end, &state);
if (count < 0)
- {
- /* Cannot convert. */
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Cannot convert. */
+ goto fail_with_EILSEQ;
arg_end++;
characters += count;
}
if (tmpdst == NULL)
{
free (tmpsrc);
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
+ goto fail_with_errno;
}
free (tmpsrc);
# endif
abort ();
count = local_wcrtomb (cbuf, *arg, &state);
if (count <= 0)
- {
- /* Cannot convert. */
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EILSEQ;
- return NULL;
- }
+ /* Cannot convert. */
+ goto fail_with_EILSEQ;
ENSURE_ALLOCATION (xsum (length, count));
memcpy (result + length, cbuf, count);
length += count;
NULL,
NULL, &tmpdst_len);
if (tmpdst == NULL)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
# endif
if (has_width)
errno = EINVAL;
}
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
-
- return NULL;
+ goto fail_with_errno;
}
#if USE_SNPRINTF
NULL,
NULL, &tmpdst_len);
if (tmpdst == NULL)
- {
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- return NULL;
- }
+ goto fail_with_errno;
ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
{ free (tmpdst); goto out_of_memory; });
DCHAR_CPY (result + length, tmpdst, tmpdst_len);
#if USE_SNPRINTF
overflow:
- if (result != resultbuf)
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
errno = EOVERFLOW;
- return NULL;
+ goto fail_with_errno;
#endif
out_of_memory:
+ errno = ENOMEM;
+ goto fail_with_errno;
+
+#if ENABLE_UNISTDIO || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T)
+ fail_with_EILSEQ:
+ errno = EILSEQ;
+ goto fail_with_errno;
+#endif
+
+ fail_with_errno:
if (result != resultbuf)
free (result);
if (buf_malloced != NULL)
free (buf_malloced);
- out_of_memory_1:
CLEANUP ();
- errno = ENOMEM;
return NULL;
}
+
+ out_of_memory_1:
+ errno = ENOMEM;
+ goto fail_1_with_errno;
+
+ fail_1_with_EINVAL:
+ errno = EINVAL;
+ goto fail_1_with_errno;
+
+ fail_1_with_errno:
+ CLEANUP ();
+ return NULL;
}
#undef MAX_ROOM_NEEDED