-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create 0001-switch-console-crash.patch
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
diff --git a/src/switch_console.c b/src/switch_console.c | ||
index 876b774..048a3cf 100644 | ||
--- a/src/switch_console.c | ||
+++ b/src/switch_console.c | ||
@@ -150,8 +150,6 @@ | ||
SWITCH_DECLARE_NONSTD(switch_status_t) switch_console_stream_write(switch_stream_handle_t *handle, const char *fmt, ...) | ||
{ | ||
va_list ap; | ||
- char *buf = handle->data; | ||
- char *end = handle->end; | ||
int ret = 0; | ||
char *data = NULL; | ||
|
||
@@ -160,44 +158,16 @@ | ||
} | ||
|
||
va_start(ap, fmt); | ||
- //ret = switch_vasprintf(&data, fmt, ap); | ||
if (!(data = switch_vmprintf(fmt, ap))) { | ||
ret = -1; | ||
} | ||
va_end(ap); | ||
|
||
if (data) { | ||
- switch_size_t remaining = handle->data_size - handle->data_len; | ||
- switch_size_t need = strlen(data) + 1; | ||
- | ||
- if ((remaining < need) && handle->alloc_len) { | ||
- switch_size_t new_len; | ||
- void *new_data; | ||
- | ||
- new_len = handle->data_size + need + handle->alloc_chunk; | ||
- if ((new_data = realloc(handle->data, new_len))) { | ||
- handle->data_size = handle->alloc_len = new_len; | ||
- handle->data = new_data; | ||
- buf = handle->data; | ||
- remaining = handle->data_size - handle->data_len; | ||
- handle->end = (uint8_t *) (handle->data) + handle->data_len; | ||
- end = handle->end; | ||
- } else { | ||
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); | ||
- free(data); | ||
- return SWITCH_STATUS_FALSE; | ||
- } | ||
- } | ||
- | ||
- if (remaining < need) { | ||
- ret = -1; | ||
- } else { | ||
- ret = 0; | ||
- switch_snprintf(end, remaining, "%s", data); | ||
- handle->data_len = strlen(buf); | ||
- handle->end = (uint8_t *) (handle->data) + handle->data_len; | ||
- } | ||
+ switch_size_t datalen = strlen(data); | ||
+ switch_status_t res = switch_console_stream_raw_write(handle, (uint8_t *)data, datalen); | ||
free(data); | ||
+ return res; | ||
} | ||
|
||
return ret ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS; |