portability
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@87 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/skeletons/OBJECT_IDENTIFIER.c b/skeletons/OBJECT_IDENTIFIER.c
index 1e4fe59..0f71307 100644
--- a/skeletons/OBJECT_IDENTIFIER.c
+++ b/skeletons/OBJECT_IDENTIFIER.c
@@ -367,6 +367,7 @@
uint8_t buffer[arcval_size];
#else
uint8_t *buffer = alloca(arcval_size);
+ if(!buffer) { errno = ENOMEM; return -1; }
#endif
if(isLittleEndian && !prepared_order) {
diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c
index 2fd0ac9..dc699f5 100644
--- a/skeletons/constr_SET.c
+++ b/skeletons/constr_SET.c
@@ -447,6 +447,12 @@
if(t2m_build_own) {
t2m = alloca(specs->elements_count * sizeof(t2m[0]));
t2m_count = 0;
+ if(!t2m) { /* There are such platforms */
+ my_erval.encoded = -1;
+ my_erval.failed_type = sd;
+ my_erval.structure_ptr = ptr;
+ return my_erval;
+ }
} else {
/*
* There is no untagged CHOICE in this SET.
diff --git a/skeletons/constraints.c b/skeletons/constraints.c
index cf31706..5f01cc7 100644
--- a/skeletons/constraints.c
+++ b/skeletons/constraints.c
@@ -108,7 +108,7 @@
*/
len = ret + 1;
p = alloca(len);
- if(!p) return; /* Can't be though. */
+ if(!p) return; /* Can fail on !x86. */
va_start(ap, fmt);
diff --git a/skeletons/der_encoder.c b/skeletons/der_encoder.c
index 919350c..dc547a2 100644
--- a/skeletons/der_encoder.c
+++ b/skeletons/der_encoder.c
@@ -60,7 +60,10 @@
*/
int stag_offset;
tags = alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
- if(tags == NULL) return -1; /* Impossible on i386 */
+ if(!tags) { /* Can fail on !x86 */
+ errno = ENOMEM;
+ return -1;
+ }
tags_count = sd->tags_count
+ 1 /* EXPLICIT or IMPLICIT tag is given */
- ((tag_mode==-1)?sd->tags_impl_skip:0);
@@ -79,7 +82,10 @@
return 0;
lens = alloca(tags_count * sizeof(lens[0]));
- if(lens == NULL) return -1;
+ if(!lens) {
+ errno = ENOMEM;
+ return -1;
+ }
/*
* Array of tags is initialized.