diff options
author | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2012-01-23 04:08:46 -0500 |
---|---|---|
committer | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2012-01-23 04:08:46 -0500 |
commit | b37f787130c8084ff147419224bfe76c128ef0c2 (patch) | |
tree | 0e32af8d9b5b74382a700d93c7a7293ef1805479 /libarchive/archive_string_sprintf.c | |
parent | 8f230c6c30a4e9bc93454f4a5b4b4cf0e3597c31 (diff) | |
download | libarchive-b37f787130c8084ff147419224bfe76c128ef0c2.tar.gz |
When ENOMEM happened in archive_string_append_from_wcs and archive_string_append_from_mbs,
those function should report the error to the caller instead of invoking __archive_errx().
We should report that ENOMEM error as possible as we can and we still need to further
improve reporting ENOEM.
SVN-Revision: 4193
Diffstat (limited to 'libarchive/archive_string_sprintf.c')
-rw-r--r-- | libarchive/archive_string_sprintf.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libarchive/archive_string_sprintf.c b/libarchive/archive_string_sprintf.c index 7d7d9713..fb752a21 100644 --- a/libarchive/archive_string_sprintf.c +++ b/libarchive/archive_string_sprintf.c @@ -146,7 +146,9 @@ archive_string_vsprintf(struct archive_string *as, const char *fmt, pw = va_arg(ap, wchar_t *); if (pw == NULL) pw = L"(null)"; - archive_string_append_from_wcs(as, pw, wcslen(pw)); + if (archive_string_append_from_wcs(as, pw, + wcslen(pw)) != 0 && errno == ENOMEM) + __archive_errx(1, "Out of memory"); break; default: p2 = va_arg(ap, char *); @@ -160,7 +162,9 @@ archive_string_vsprintf(struct archive_string *as, const char *fmt, pw = va_arg(ap, wchar_t *); if (pw == NULL) pw = L"(null)"; - archive_string_append_from_wcs(as, pw, wcslen(pw)); + if (archive_string_append_from_wcs(as, pw, + wcslen(pw)) != 0 && errno == ENOMEM) + __archive_errx(1, "Out of memory"); break; case 'o': case 'u': case 'x': case 'X': /* Common handling for unsigned integer formats. */ |