Diffstat (limited to 'noncore/todayplugins/stockticker/libstocks') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/http.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/todayplugins/stockticker/libstocks/http.c b/noncore/todayplugins/stockticker/libstocks/http.c index 2f38f8a..cc78ab7 100644 --- a/noncore/todayplugins/stockticker/libstocks/http.c +++ b/noncore/todayplugins/stockticker/libstocks/http.c @@ -165,97 +165,97 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) { if((data = malloc(r+1))==NULL) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } memcpy(data,buf,r); data_lgr = r; data[r]=0; } else { if((temp = malloc(r+data_lgr+1))==NULL) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } memcpy(temp, data, data_lgr); memcpy(temp+data_lgr, buf, r); temp[r+data_lgr]=0; data_lgr += r; free(data); data = temp; } } } /* close socket */ #ifdef __UNIX__ close(s); #elif __WINDOWS__ closesocket(s); #endif #ifdef DEBUG printf("%s\n", data); #endif /* get headers to test status line */ /* and to split headers and content */ temp = data; header_founded = 0; while( !header_founded ) { - if (*temp==0) return ERRRHEA; + if (!temp || *temp==0) return ERRRHEA; if( *temp==0x0A ) { /* test if it is the header end */ temp ++; if (*temp == 0x0D) temp++; if (*temp == 0x0A) header_founded = 1; } else temp++; } *temp = 0; temp++; sscanf(data,"HTTP/1.%*d %03d",&error_code); if (error_code != 200) { #ifdef DEBUG printf(" HTTP error code : %d\n", error_code); #endif free(data); return ERRPAHD; } if ((csv_ptr = malloc(strlen(temp)+1))==NULL) { free(data); fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } memcpy(csv_ptr, temp, strlen(temp)+1); free(data); #ifdef DEBUG printf(" CSV\n"); printf("%s,\n", csv_ptr); #endif *pdata = csv_ptr; return 0; } /******************************************************************************/ |