diff options
author | Guy Harris <gharris@sonic.net> | 2021-05-21 18:33:56 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-05-21 18:33:56 -0700 |
commit | f1ffe7d4215ac1cc80d9596e6604b30ddfa59fcf (patch) | |
tree | d5b566e3a67e155abbd0bd0ae0f74af9a420c873 | |
parent | eb75366bc460c80dce1f70bd635d3739b61e476f (diff) |
protobuf: close a leak when file loading fails.
Free the path we've constructed before returning a failure indication if
pbw_load_proto_file() or load_all_files_in_dir() reports a failure.
Also, explicitly compare pbw_load_proto_file()'s return value against 0,
to make it a little clearer that it's *not* a Boolean, it's a return
code (with 0 meaning success and different non-zero values meaning
failure; if it matters *which* failure it is, we should probably have
otherwise we should just make it a Boolean).
-rw-r--r-- | epan/dissectors/packet-protobuf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/epan/dissectors/packet-protobuf.c b/epan/dissectors/packet-protobuf.c index 0dc54a855e..ac886c3923 100644 --- a/epan/dissectors/packet-protobuf.c +++ b/epan/dissectors/packet-protobuf.c @@ -1448,11 +1448,13 @@ load_all_files_in_dir(PbwDescriptorPool* pool, const gchar* dir_path) dot = strrchr(name, '.'); if (dot && g_ascii_strcasecmp(dot + 1, "proto") == 0) { /* Note: pbw_load_proto_file support absolute or relative (to one of search paths) path */ - if (pbw_load_proto_file(pool, path)) { + if (pbw_load_proto_file(pool, path) != 0) { + g_free(path); return FALSE; } } else { if (!load_all_files_in_dir(pool, path)) { + g_free(path); return FALSE; } } |