Skip to content

Commit 358b9f1

Browse files
committed
fix UB of setjmp usage
1 parent 7f92d67 commit 358b9f1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pb.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -1616,17 +1616,16 @@ static void pbL_loadFile(pb_State *S, pbL_FileInfo *info, pb_Loader *L) {
16161616
}
16171617

16181618
PB_API int pb_load(pb_State *S, pb_Slice *s) {
1619+
volatile int ret = PB_ERROR;
16191620
pbL_FileInfo *files = NULL;
16201621
pb_Loader L;
1621-
int ret;
1622-
if ((ret = setjmp(L.jbuf)) < 0)
1623-
return PB_ERROR;
1624-
else if (ret == 0) {
1622+
if (!setjmp(L.jbuf)) {
16251623
L.s = *s;
16261624
L.is_proto3 = 0;
16271625
pb_initbuffer(&L.b);
16281626
pbL_FileDescriptorSet(&L, &files);
16291627
pbL_loadFile(S, files, &L);
1628+
ret = PB_OK;
16301629
}
16311630
pbL_delFileInfo(files);
16321631
pb_resetbuffer(&L.b);

0 commit comments

Comments
 (0)