Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/x509.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,16 @@ Local<Value> try_parse(const std::string& dataString) {
BUF_MEM *bptr;
BIO_get_mem_ptr(ext_bio, &bptr);
BIO_set_close(ext_bio, BIO_CLOSE);

char *data = (char*) malloc(bptr->length + 1);
BUF_strlcpy(data, bptr->data, bptr->length + 1);
data = trim(data, bptr->length);

BIO_free(ext_bio);
if (bptr->data == NULL){
Copy link
Owner

@Southern Southern Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the better option would be to not run the allocation or anything that deals with data unless bptr->data != NULL.

BIO_free(ext_bio);
data="";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

free(data) :)

} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove else, please.

BUF_strlcpy(data, bptr->data, bptr->length );
data = trim(data, bptr->length);
BIO_free(ext_bio);
}

unsigned nid = OBJ_obj2nid(obj);
if (nid == NID_undef) {
Expand Down