aboutsummaryrefslogtreecommitdiff
path: root/iconvdata/iso-2022-jp.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-12-17 12:10:58 +0000
committerUlrich Drepper <drepper@redhat.com>1998-12-17 12:10:58 +0000
commit0937645101948542e6d0936546e9ca048847c24b (patch)
treef8b5594effce142c70526d9d683bd09dd619d9ad /iconvdata/iso-2022-jp.c
parentc7ec9d75a79e1ed2d558447ba788318d3f1fb76c (diff)
downloadglibc-0937645101948542e6d0936546e9ca048847c24b.zip
glibc-0937645101948542e6d0936546e9ca048847c24b.tar.gz
glibc-0937645101948542e6d0936546e9ca048847c24b.tar.bz2
Update.
* iconvdata/iso646.c (gconv_init): Return correct error value if we run out of memory. * iconvdata/iso-2022-jp.c: Likewise.
Diffstat (limited to 'iconvdata/iso-2022-jp.c')
-rw-r--r--iconvdata/iso-2022-jp.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/iconvdata/iso-2022-jp.c b/iconvdata/iso-2022-jp.c
index e888d31..36465cc 100644
--- a/iconvdata/iso-2022-jp.c
+++ b/iconvdata/iso-2022-jp.c
@@ -132,34 +132,38 @@ gconv_init (struct gconv_step *step)
}
result = GCONV_NOCONV;
- if (dir != illegal_dir
- && ((new_data
- = (struct iso2022jp_data *) malloc (sizeof (struct iso2022jp_data)))
- != NULL))
+ if (dir != illegal_dir)
{
- new_data->dir = dir;
- new_data->var = var;
- step->data = new_data;
+ new_data
+ = (struct iso2022jp_data *) malloc (sizeof (struct iso2022jp_data));
- if (dir == from_iso2022jp)
+ result = GCONV_NOMEM;
+ if (new_data != NULL)
{
- step->min_needed_from = MIN_NEEDED_FROM;
- step->max_needed_from = MAX_NEEDED_FROM;
- step->min_needed_to = MIN_NEEDED_TO;
- step->max_needed_to = MIN_NEEDED_TO;
+ new_data->dir = dir;
+ new_data->var = var;
+ step->data = new_data;
+
+ if (dir == from_iso2022jp)
+ {
+ step->min_needed_from = MIN_NEEDED_FROM;
+ step->max_needed_from = MAX_NEEDED_FROM;
+ step->min_needed_to = MIN_NEEDED_TO;
+ step->max_needed_to = MIN_NEEDED_TO;
+ }
+ else
+ {
+ step->min_needed_from = MIN_NEEDED_TO;
+ step->max_needed_from = MAX_NEEDED_TO;
+ step->min_needed_to = MIN_NEEDED_FROM;
+ step->max_needed_to = MIN_NEEDED_FROM + 2;
+ }
+
+ /* Yes, this is a stateful encoding. */
+ step->stateful = 1;
+
+ result = GCONV_OK;
}
- else
- {
- step->min_needed_from = MIN_NEEDED_TO;
- step->max_needed_from = MAX_NEEDED_TO;
- step->min_needed_to = MIN_NEEDED_FROM;
- step->max_needed_to = MIN_NEEDED_FROM + 2;
- }
-
- /* Yes, this is a stateful encoding. */
- step->stateful = 1;
-
- result = GCONV_OK;
}
return result;