From 8334e2bf1f3a92ff7af37adfb15fc977a361f772 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 28 Jan 2019 10:32:34 +0000 Subject: [PATCH] Still segfaults on read from URL. --- src/init.c | 4 ++++ src/io/fopen.c | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/init.c b/src/init.c index 2814f1d..1fba3f2 100644 --- a/src/init.c +++ b/src/init.c @@ -16,6 +16,9 @@ #include #include +/* libcurl, used for io */ +#include + #include "version.h" #include "conspage.h" #include "consspaceobject.h" @@ -84,6 +87,7 @@ int main( int argc, char *argv[] ) { bool show_prompt = false; setlocale( LC_ALL, "" ); + curl_global_init(CURL_GLOBAL_DEFAULT); while ( ( option = getopt( argc, argv, "cpdv:" ) ) != -1 ) { switch ( option ) { diff --git a/src/io/fopen.c b/src/io/fopen.c index 3b09957..a2eddab 100644 --- a/src/io/fopen.c +++ b/src/io/fopen.c @@ -460,14 +460,11 @@ wint_t url_fgetwc( URL_FILE * input ) { case CFTYPE_CURL:{ wchar_t *wbuff = calloc( 2, sizeof( wchar_t ) ); - char *cbuff = calloc( 5, sizeof( char ) ); - url_fread( cbuff, sizeof( char ), 4, input ); - mbstowcs( wbuff, cbuff, 1 ); + mbstowcs( wbuff, (char *)&input->buffer[input->buffer_pos], 1 ); result = wbuff[0]; use_one_wide( input ); - free( cbuff ); free( wbuff ); } break;