Skip to content

Commit

Permalink
Merge pull request #119 from mcara/fix-logging
Browse files Browse the repository at this point in the history
Fix segfault on some systems
  • Loading branch information
mcara authored Oct 2, 2023
2 parents e0dabbb + b623428 commit a2665bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
9 changes: 8 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
Release Notes
=============

.. 1.14.2 (unreleased)
.. 1.14.4 (unreleased)
===================
1.14.3 (2023-10-02)
===================

- Disable logging to fix a segfault on some systems. [#119]


1.14.2 (2023-09-16)
===================

Expand Down
18 changes: 12 additions & 6 deletions src/cdrizzleutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ driz_param_dump(struct driz_param_t* p);
/****************************************************************************/
/* LOGGING */

#define LOGGING

#ifdef LOGGING
extern FILE *driz_log_handle;

Expand All @@ -203,24 +201,32 @@ driz_log_init(FILE *handle) {
}
}
if (!p) {
sprintf(buf, "%ctmp%cdrizzle.log", dirsep, dirsep);
sprintf(buf, "drizzle.log");
}

handle = fopen(buf, "a");
setbuf(handle, 0);
if (handle) {
setbuf(handle, 0);
}
return handle;
}


static inline_macro int
driz_log_close(FILE *handle) {
return fclose(driz_log_handle);
if (handle) {
return fclose(handle);
}
}

static inline_macro int
driz_log_message(const char* message) {
if (! driz_log_handle)
if (!driz_log_handle) {
driz_log_handle = driz_log_init(driz_log_handle);
if (!driz_log_handle) {
return 1;
}
}

fputs(message, driz_log_handle);
fputs("\n", driz_log_handle);
Expand Down

0 comments on commit a2665bf

Please sign in to comment.