nghttp2_hd_*_new: Leave *inflater_ptr or *deflater_ptr untouched on failure
This commit is contained in:
parent
55c338d7af
commit
16fef227e8
|
@ -2784,6 +2784,8 @@ typedef struct nghttp2_hd_deflater nghttp2_hd_deflater;
|
||||||
* The |deflate_hd_table_bufsize_max| is the upper bound of header
|
* The |deflate_hd_table_bufsize_max| is the upper bound of header
|
||||||
* table size the deflater will use.
|
* table size the deflater will use.
|
||||||
*
|
*
|
||||||
|
* If this function fails, |*deflater_ptr| is left untouched.
|
||||||
|
*
|
||||||
* This function returns 0 if it succeeds, or one of the following
|
* This function returns 0 if it succeeds, or one of the following
|
||||||
* negative error codes:
|
* negative error codes:
|
||||||
*
|
*
|
||||||
|
@ -2892,6 +2894,8 @@ typedef struct nghttp2_hd_inflater nghttp2_hd_inflater;
|
||||||
*
|
*
|
||||||
* Initializes |*inflater_ptr| for inflating name/values pairs.
|
* Initializes |*inflater_ptr| for inflating name/values pairs.
|
||||||
*
|
*
|
||||||
|
* If this function fails, |*inflater_ptr| is left untouched.
|
||||||
|
*
|
||||||
* This function returns 0 if it succeeds, or one of the following
|
* This function returns 0 if it succeeds, or one of the following
|
||||||
* negative error codes:
|
* negative error codes:
|
||||||
*
|
*
|
||||||
|
|
|
@ -1315,13 +1315,24 @@ size_t nghttp2_hd_deflate_bound(nghttp2_hd_deflater *deflater,
|
||||||
int nghttp2_hd_deflate_new(nghttp2_hd_deflater **deflater_ptr,
|
int nghttp2_hd_deflate_new(nghttp2_hd_deflater **deflater_ptr,
|
||||||
size_t deflate_hd_table_bufsize_max)
|
size_t deflate_hd_table_bufsize_max)
|
||||||
{
|
{
|
||||||
*deflater_ptr = malloc(sizeof(nghttp2_hd_deflater));
|
int rv;
|
||||||
|
nghttp2_hd_deflater *deflater;
|
||||||
|
|
||||||
if(*deflater_ptr == NULL) {
|
deflater = malloc(sizeof(nghttp2_hd_deflater));
|
||||||
|
|
||||||
|
if(deflater == NULL) {
|
||||||
return NGHTTP2_ERR_NOMEM;
|
return NGHTTP2_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nghttp2_hd_deflate_init2(*deflater_ptr, deflate_hd_table_bufsize_max);
|
rv = nghttp2_hd_deflate_init2(deflater, deflate_hd_table_bufsize_max);
|
||||||
|
|
||||||
|
if(rv != 0) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
*deflater_ptr = deflater;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nghttp2_hd_deflate_del(nghttp2_hd_deflater *deflater)
|
void nghttp2_hd_deflate_del(nghttp2_hd_deflater *deflater)
|
||||||
|
@ -2015,13 +2026,24 @@ int nghttp2_hd_inflate_end_headers(nghttp2_hd_inflater *inflater)
|
||||||
|
|
||||||
int nghttp2_hd_inflate_new(nghttp2_hd_inflater **inflater_ptr)
|
int nghttp2_hd_inflate_new(nghttp2_hd_inflater **inflater_ptr)
|
||||||
{
|
{
|
||||||
*inflater_ptr = malloc(sizeof(nghttp2_hd_inflater));
|
int rv;
|
||||||
|
nghttp2_hd_inflater *inflater;
|
||||||
|
|
||||||
if(*inflater_ptr == NULL) {
|
inflater = malloc(sizeof(nghttp2_hd_inflater));
|
||||||
|
|
||||||
|
if(inflater == NULL) {
|
||||||
return NGHTTP2_ERR_NOMEM;
|
return NGHTTP2_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nghttp2_hd_inflate_init(*inflater_ptr);
|
rv = nghttp2_hd_inflate_init(inflater);
|
||||||
|
|
||||||
|
if(rv != 0) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
*inflater_ptr = inflater;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nghttp2_hd_inflate_del(nghttp2_hd_inflater *inflater)
|
void nghttp2_hd_inflate_del(nghttp2_hd_inflater *inflater)
|
||||||
|
|
Loading…
Reference in New Issue