Skip to content
Snippets Groups Projects
Commit cd1ab8d1 authored by Tommy Olofsson's avatar Tommy Olofsson
Browse files

Try to catch memory errors.

parent 4bb8da74
Branches
No related tags found
No related merge requests found
...@@ -158,6 +158,10 @@ static int decode_sample_def_or_ref(struct labcomm2014_decoder *d, int kind) ...@@ -158,6 +158,10 @@ static int decode_sample_def_or_ref(struct labcomm2014_decoder *d, int kind)
goto out; goto out;
} }
signature.name = labcomm2014_read_string(d->reader); signature.name = labcomm2014_read_string(d->reader);
if (signature.name == NULL) {
result = -ENOMEM;
goto out;
}
if (d->reader->error < 0) { if (d->reader->error < 0) {
result = d->reader->error; result = d->reader->error;
goto free_signature_name; goto free_signature_name;
...@@ -168,6 +172,10 @@ static int decode_sample_def_or_ref(struct labcomm2014_decoder *d, int kind) ...@@ -168,6 +172,10 @@ static int decode_sample_def_or_ref(struct labcomm2014_decoder *d, int kind)
goto free_signature_name; goto free_signature_name;
} }
signature.signature = labcomm2014_memory_alloc(d->memory, 1, signature.size); signature.signature = labcomm2014_memory_alloc(d->memory, 1, signature.size);
if (signature.signature == NULL) {
result = -ENOMEM;
goto free_signature_name;
}
if (d->reader->error < 0) { if (d->reader->error < 0) {
result = d->reader->error; result = d->reader->error;
goto free_signature_name; goto free_signature_name;
...@@ -253,6 +261,10 @@ static int decode_pragma(struct labcomm2014_decoder *d, ...@@ -253,6 +261,10 @@ static int decode_pragma(struct labcomm2014_decoder *d,
char *pragma_type; char *pragma_type;
int result; int result;
pragma_type = labcomm2014_read_string(d->reader); pragma_type = labcomm2014_read_string(d->reader);
if (pragma_type == NULL) {
result = -ENOMEM;
goto out;
}
if (d->reader->error < 0) { if (d->reader->error < 0) {
result = d->reader->error; result = d->reader->error;
goto out; goto out;
...@@ -346,7 +358,9 @@ static int do_decode_one(struct labcomm2014_decoder *d) ...@@ -346,7 +358,9 @@ static int do_decode_one(struct labcomm2014_decoder *d)
} }
if (remote_index == LABCOMM_VERSION) { if (remote_index == LABCOMM_VERSION) {
char *version = labcomm2014_read_string(d->reader); char *version = labcomm2014_read_string(d->reader);
if (d->reader->error < 0) { if (version == NULL) {
result = -ENOMEM;
} else if (d->reader->error < 0) {
result = d->reader->error; result = d->reader->error;
} else if (strcmp(version, CURRENT_VERSION) == 0) { } else if (strcmp(version, CURRENT_VERSION) == 0) {
result = LABCOMM_VERSION; result = LABCOMM_VERSION;
...@@ -488,6 +502,7 @@ static void decode_raw_type_def( ...@@ -488,6 +502,7 @@ static void decode_raw_type_def(
v.index = labcomm2014_read_packed32(r); v.index = labcomm2014_read_packed32(r);
if (r->error < 0) { goto out; } if (r->error < 0) { goto out; }
v.name = labcomm2014_read_string(r); v.name = labcomm2014_read_string(r);
if (v.name == NULL) { goto out; }
if (r->error < 0) { goto free_name; } if (r->error < 0) { goto free_name; }
v.length = labcomm2014_read_packed32(r); v.length = labcomm2014_read_packed32(r);
if (r->error < 0) { goto free_name; } if (r->error < 0) { goto free_name; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment