mirror of
https://github.com/moparisthebest/curl
synced 2025-03-11 07:39:50 -04:00
Using fdopen() is a more correct way to implement the CURLOPT_NEW_FILE_PREMS
file.c, but the debug interface was missing. This adds the routines needed to make the memory debuging work for fdopen().
This commit is contained in:
parent
d500c468fc
commit
aed0cc6f2a
@ -231,8 +231,7 @@ static CURLcode file_upload(struct connectdata *conn)
|
|||||||
failf(data, "Can't open %s for writing", file->path);
|
failf(data, "Can't open %s for writing", file->path);
|
||||||
return CURLE_WRITE_ERROR;
|
return CURLE_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
close(fd);
|
fp = fdopen(fd, "wb");
|
||||||
fp = fopen(file->path, "wb");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
|
@ -280,6 +280,16 @@ FILE *curl_fopen(const char *file, const char *mode,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE *curl_fdopen(int filedes, const char *mode,
|
||||||
|
int line, const char *source)
|
||||||
|
{
|
||||||
|
FILE *res=(fdopen)(filedes, mode);
|
||||||
|
if(logfile)
|
||||||
|
fprintf(logfile, "FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n",
|
||||||
|
source, line, filedes, mode, res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
int curl_fclose(FILE *file, int line, const char *source)
|
int curl_fclose(FILE *file, int line, const char *source)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@ -67,6 +67,8 @@ CURL_EXTERN int curl_accept(int s, void *addr, void *addrlen,
|
|||||||
/* FILE functions */
|
/* FILE functions */
|
||||||
CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line,
|
CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line,
|
||||||
const char *source);
|
const char *source);
|
||||||
|
CURL_EXTERN FILE *curl_fdopen(int filedes, const char *mode, int line,
|
||||||
|
const char *source);
|
||||||
CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
|
CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
|
||||||
|
|
||||||
#ifndef MEMDEBUG_NODEFINES
|
#ifndef MEMDEBUG_NODEFINES
|
||||||
@ -117,6 +119,8 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
|
|||||||
|
|
||||||
#undef fopen
|
#undef fopen
|
||||||
#define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
|
#define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
|
||||||
|
#undef fdopen
|
||||||
|
#define fdopen(file,mode) curl_fdopen(file,mode,__LINE__,__FILE__)
|
||||||
#define fclose(file) curl_fclose(file,__LINE__,__FILE__)
|
#define fclose(file) curl_fclose(file,__LINE__,__FILE__)
|
||||||
|
|
||||||
#endif /* MEMDEBUG_NODEFINES */
|
#endif /* MEMDEBUG_NODEFINES */
|
||||||
|
@ -237,7 +237,7 @@ while(<FILE>) {
|
|||||||
$linenum = $2;
|
$linenum = $2;
|
||||||
$function = $3;
|
$function = $3;
|
||||||
|
|
||||||
if($function =~ /fopen\(\"([^\"]*)\",\"([^\"]*)\"\) = (\(nil\)|0x([0-9a-f]*))/) {
|
if($function =~ /f[d]*open\(\"([^\"]*)\",\"([^\"]*)\"\) = (\(nil\)|0x([0-9a-f]*))/) {
|
||||||
if($3 eq "(nil)") {
|
if($3 eq "(nil)") {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user