• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Pipewireパッケージ(ちょっと変更)


Commit MetaInfo

Revisión37b2633756dad1c1f133bf58209df224cca2297b (tree)
Tiempo2023-09-30 01:19:13
AutorBarnabás Pőcze <pobrn@prot...>
CommiterBarnabás Pőcze

Log Message

pulse-server: reorder initialization to make proper cleanup possible

Previously, in case of errors, the struct members were not disposed of
correctly, leading to memory leaks. Reordering the initialization slightly
makes it possible to call impl_free().

See https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1840#note_2106874

Cambiar Resumen

Diferencia incremental

--- a/src/modules/module-protocol-pulse/pulse-server.c
+++ b/src/modules/module-protocol-pulse/pulse-server.c
@@ -5483,9 +5483,23 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
54835483 const char *str;
54845484 int res = 0;
54855485
5486+ debug_messages = pw_log_topic_enabled(SPA_LOG_LEVEL_INFO, pulse_conn);
5487+
54865488 impl = calloc(1, sizeof(*impl) + user_data_size);
54875489 if (impl == NULL)
5488- goto error_exit;
5490+ goto error_free_props;
5491+
5492+ impl->rate_limit.interval = 2 * SPA_NSEC_PER_SEC;
5493+ impl->rate_limit.burst = 1;
5494+ spa_hook_list_init(&impl->hooks);
5495+ spa_list_init(&impl->servers);
5496+ pw_map_init(&impl->samples, 16, 16);
5497+ pw_map_init(&impl->modules, 16, 16);
5498+ spa_list_init(&impl->cleanup_clients);
5499+ spa_list_init(&impl->free_messages);
5500+
5501+ impl->loop = pw_context_get_main_loop(context);
5502+ impl->work_queue = pw_context_get_work_queue(context);
54895503
54905504 if (props == NULL)
54915505 props = pw_properties_new(NULL, NULL);
@@ -5503,25 +5517,6 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
55035517 pw_properties_set(props, "vm.overrides", NULL);
55045518 }
55055519
5506- load_defaults(&impl->defs, props);
5507-
5508- debug_messages = pw_log_topic_enabled(SPA_LOG_LEVEL_INFO, pulse_conn);
5509-
5510- impl->context = context;
5511- impl->loop = pw_context_get_main_loop(context);
5512- impl->props = props;
5513-
5514- impl->work_queue = pw_context_get_work_queue(context);
5515-
5516- spa_hook_list_init(&impl->hooks);
5517- spa_list_init(&impl->servers);
5518- impl->rate_limit.interval = 2 * SPA_NSEC_PER_SEC;
5519- impl->rate_limit.burst = 1;
5520- pw_map_init(&impl->samples, 16, 16);
5521- pw_map_init(&impl->modules, 16, 16);
5522- spa_list_init(&impl->cleanup_clients);
5523- spa_list_init(&impl->free_messages);
5524-
55255520 str = pw_properties_get(props, "server.address");
55265521 if (str == NULL) {
55275522 pw_properties_setf(props, "server.address",
@@ -5544,8 +5539,6 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
55445539 pw_log_warn("%p: can't create pid file: %s",
55455540 impl, spa_strerror(res));
55465541 }
5547- pw_context_add_listener(context, &impl->context_listener,
5548- &context_events, impl);
55495542
55505543 #ifdef HAVE_DBUS
55515544 str = pw_properties_get(props, "server.dbus-name");
@@ -5554,14 +5547,22 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
55545547 if (strlen(str) > 0)
55555548 impl->dbus_name = dbus_request_name(context, str);
55565549 #endif
5550+
5551+ load_defaults(&impl->defs, props);
5552+ impl->props = spa_steal_ptr(props);
5553+
5554+ pw_context_add_listener(context, &impl->context_listener,
5555+ &context_events, impl);
5556+ impl->context = context;
5557+
55575558 cmd_run(impl);
55585559
55595560 return (struct pw_protocol_pulse *) impl;
55605561
55615562 error_free:
5562- free(impl);
5563+ impl_free(impl);
55635564
5564-error_exit:
5565+error_free_props:
55655566 pw_properties_free(props);
55665567
55675568 if (res < 0)