Skip to content

Commit 5433fc3

Browse files
Encoder: Fix the returning of OOM errors in closing containers
Conditional added by 3369dd1 was inverted. Signed-off-by: Thiago Macieira <[email protected]>
1 parent 4df8364 commit 5433fc3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/cborencoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ CborError cbor_encoder_close_container(CborEncoder *encoder, const CborEncoder *
535535
encoder->end = containerEncoder->end;
536536
if (containerEncoder->flags & CborIteratorFlag_UnknownLength)
537537
return append_byte_to_buffer(encoder, BreakByte);
538-
if (encoder->end)
538+
if (!encoder->end)
539539
return CborErrorOutOfMemory; /* keep the state */
540540
return CborNoError;
541541
}

tests/encoder/tst_encoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ CborError encodeVariant(CborEncoder *encoder, const QVariant &v)
225225
if (err && !isOomError(err))
226226
return err;
227227
}
228-
return static_cast<CborError>(err | cbor_encoder_close_container_checked(encoder, &sub));
228+
return cbor_encoder_close_container_checked(encoder, &sub);
229229
}
230230
if (type == qMetaTypeId<Map>() || type == qMetaTypeId<IndeterminateLengthMap>()) {
231231
CborEncoder sub;
@@ -246,7 +246,7 @@ CborError encodeVariant(CborEncoder *encoder, const QVariant &v)
246246
if (err && !isOomError(err))
247247
return err;
248248
}
249-
return (CborError)(err | cbor_encoder_close_container_checked(encoder, &sub));
249+
return cbor_encoder_close_container_checked(encoder, &sub);
250250
}
251251
}
252252
return CborErrorUnknownType;

0 commit comments

Comments
 (0)