forked from osmocom/wireshark
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).
(cherry picked from commit f1ffe7d421
)
This commit is contained in:
parent
4a17759938
commit
161e765500
|
@ -1142,11 +1142,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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue