Skip to content

Commit

Permalink
Fix missing null-check for 'Soup.MessageHeaders.get_content_type'
Browse files Browse the repository at this point in the history
Fix #211 by resolving the caused memory leak.
  • Loading branch information
arteymix committed Jun 15, 2017
1 parent 0f0592a commit 6bf69d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/valum/valum-content-negotiation.vala
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ namespace Valum.ContentNegotiation {
return negotiate ("Accept-Charset", charsets, (req, res, next, ctx, charset) => {
HashTable<string, string> @params;
var content_type = res.headers.get_content_type (out @params) ?? "application/octet-stream";
if (@params == null) {
@params = new HashTable<string, string> ((GLib.HashFunc<string>) Soup.str_case_hash,
(GLib.EqualFunc<string>) Soup.str_case_equal);
}
@params["charset"] = charset;
res.headers.set_content_type (content_type, @params);
return forward (req, res, next, ctx, charset);
Expand Down
2 changes: 1 addition & 1 deletion src/valum/valum-multipart.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Valum {
return (req, res, next, ctx) => {
HashTable<string, string> @params;
if (req.headers.get_content_type (out @params).has_prefix ("multipart/")) {
if (!@params.contains ("boundary")) {
if (@params == null || !@params.contains ("boundary")) {
throw new ClientError.BAD_REQUEST ("The 'boundary' parameter is missing in the 'Content-Type' header.");
}
return forward (req, res, next, ctx, new MultipartInputStream (req.body, @params["boundary"]));
Expand Down

0 comments on commit 6bf69d6

Please sign in to comment.