mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-27 14:41:58 +00:00
Check fopen return value for ao2 reference debug output.
Reported by: wdoekes Patched by: wdoekes Review: https://reviewboard.asterisk.org/r/1539/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@342487 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -210,14 +210,19 @@ int __ao2_ref_debug(void *user_data, const int delta, char *tag, char *file, int
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (delta != 0) {
|
if (delta != 0) {
|
||||||
FILE *refo = fopen(REF_FILE,"a");
|
FILE *refo = fopen(REF_FILE, "a");
|
||||||
fprintf(refo, "%p %s%d %s:%d:%s (%s) [@%d]\n", user_data, (delta<0? "":"+"), delta, file, line, funcname, tag, obj ? obj->priv_data.ref_counter : -1);
|
if (refo) {
|
||||||
fclose(refo);
|
fprintf(refo, "%p %s%d %s:%d:%s (%s) [@%d]\n", user_data, (delta < 0 ? "" : "+"),
|
||||||
|
delta, file, line, funcname, tag, obj ? obj->priv_data.ref_counter : -1);
|
||||||
|
fclose(refo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (obj->priv_data.ref_counter + delta == 0 && obj->priv_data.destructor_fn != NULL) { /* this isn't protected with lock; just for o/p */
|
if (obj->priv_data.ref_counter + delta == 0 && obj->priv_data.destructor_fn != NULL) { /* this isn't protected with lock; just for o/p */
|
||||||
FILE *refo = fopen(REF_FILE,"a");
|
FILE *refo = fopen(REF_FILE, "a");
|
||||||
|
if (refo) {
|
||||||
fprintf(refo, "%p **call destructor** %s:%d:%s (%s)\n", user_data, file, line, funcname, tag);
|
fprintf(refo, "%p **call destructor** %s:%d:%s (%s)\n", user_data, file, line, funcname, tag);
|
||||||
fclose(refo);
|
fclose(refo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return internal_ao2_ref(user_data, delta);
|
return internal_ao2_ref(user_data, delta);
|
||||||
}
|
}
|
||||||
@@ -319,14 +324,13 @@ void *__ao2_alloc_debug(size_t data_size, ao2_destructor_fn destructor_fn, char
|
|||||||
{
|
{
|
||||||
/* allocation */
|
/* allocation */
|
||||||
void *obj;
|
void *obj;
|
||||||
FILE *refo = ref_debug ? fopen(REF_FILE,"a") : NULL;
|
FILE *refo;
|
||||||
|
|
||||||
if ((obj = internal_ao2_alloc(data_size, destructor_fn, file, line, funcname)) == NULL) {
|
if ((obj = internal_ao2_alloc(data_size, destructor_fn, file, line, funcname)) == NULL) {
|
||||||
fclose(refo);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refo) {
|
if (ref_debug && (refo = fopen(REF_FILE, "a"))) {
|
||||||
fprintf(refo, "%p =1 %s:%d:%s (%s)\n", obj, file, line, funcname, tag);
|
fprintf(refo, "%p =1 %s:%d:%s (%s)\n", obj, file, line, funcname, tag);
|
||||||
fclose(refo);
|
fclose(refo);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user