Mercurial > pidgin
comparison src/plugins.c @ 787:53d2e3e02297
[gaim-migrate @ 797]
plugging plugin leaks.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Tue, 29 Aug 2000 18:24:26 +0000 |
| parents | 4c292b3f74ea |
| children | 00c56b54e92c |
comparison
equal
deleted
inserted
replaced
| 786:ffb824f6cd24 | 787:53d2e3e02297 |
|---|---|
| 164 if (filename[0] != '/') { | 164 if (filename[0] != '/') { |
| 165 char *buf = g_malloc(BUF_LEN); | 165 char *buf = g_malloc(BUF_LEN); |
| 166 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR); | 166 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR); |
| 167 plug->filename = g_malloc(strlen(buf) + strlen(filename) + 1); | 167 plug->filename = g_malloc(strlen(buf) + strlen(filename) + 1); |
| 168 sprintf(plug->filename, "%s%s", buf, filename); | 168 sprintf(plug->filename, "%s%s", buf, filename); |
| 169 g_free(buf); | |
| 169 } else | 170 } else |
| 170 plug->filename = g_strdup(filename); | 171 plug->filename = g_strdup(filename); |
| 171 sprintf(debug_buff, "Loading %s\n", filename); | 172 sprintf(debug_buff, "Loading %s\n", filename); |
| 172 debug_print(debug_buff); | 173 debug_print(debug_buff); |
| 173 /* do NOT `OR' with RTLD_GLOBAL, otherwise plugins may conflict | 174 /* do NOT `OR' with RTLD_GLOBAL, otherwise plugins may conflict |
| 175 * programming, by not using RTLD_GLOBAL :P ) */ | 176 * programming, by not using RTLD_GLOBAL :P ) */ |
| 176 plug->handle = dlopen(plug->filename, RTLD_LAZY); | 177 plug->handle = dlopen(plug->filename, RTLD_LAZY); |
| 177 if (!plug->handle) { | 178 if (!plug->handle) { |
| 178 error = (char *)dlerror(); | 179 error = (char *)dlerror(); |
| 179 do_error_dialog(error, _("Plugin Error")); | 180 do_error_dialog(error, _("Plugin Error")); |
| 181 g_free(plug->filename); | |
| 180 g_free(plug); | 182 g_free(plug); |
| 181 return; | 183 return; |
| 182 } | 184 } |
| 183 | 185 |
| 184 gaim_plugin_init = dlsym(plug->handle, "gaim_plugin_init"); | 186 gaim_plugin_init = dlsym(plug->handle, "gaim_plugin_init"); |
| 185 if ((error = (char *)dlerror()) != NULL) { | 187 if ((error = (char *)dlerror()) != NULL) { |
| 186 do_error_dialog(error, _("Plugin Error")); | 188 do_error_dialog(error, _("Plugin Error")); |
| 187 dlclose(plug->handle); | 189 dlclose(plug->handle); |
| 190 g_free(plug->filename); | |
| 188 g_free(plug); | 191 g_free(plug); |
| 189 return; | 192 return; |
| 190 } | 193 } |
| 191 | 194 |
| 192 retval = (*gaim_plugin_init)(plug->handle); | 195 retval = (*gaim_plugin_init)(plug->handle); |
| 215 plugin_error = (*gaim_plugin_error)(retval); | 218 plugin_error = (*gaim_plugin_error)(retval); |
| 216 if (plugin_error) | 219 if (plugin_error) |
| 217 do_error_dialog(plugin_error, _("Plugin Error")); | 220 do_error_dialog(plugin_error, _("Plugin Error")); |
| 218 } | 221 } |
| 219 dlclose(plug->handle); | 222 dlclose(plug->handle); |
| 223 g_free(plug->filename); | |
| 220 g_free(plug); | 224 g_free(plug); |
| 221 return; | 225 return; |
| 222 } | 226 } |
| 223 | 227 |
| 224 plugins = g_list_append(plugins, plug); | 228 plugins = g_list_append(plugins, plug); |
