forked from jl777/komodo
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly initialize event_pubkeys #510
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,15 +135,15 @@ std::ostream& operator<<(std::ostream& os, const event& in) | |
* @param pos the starting position (will advance) | ||
* @param data_len full length of data | ||
*/ | ||
event_pubkeys::event_pubkeys(uint8_t* data, long& pos, long data_len, int32_t height) : event(EVENT_PUBKEYS, height) | ||
event_pubkeys::event_pubkeys(uint8_t* data, long& pos, long data_len, int32_t height) : event_pubkeys(height) | ||
{ | ||
num = data[pos++]; | ||
if (num > 64) | ||
throw parse_error("Illegal number of keys: " + std::to_string(num)); | ||
mem_nread(pubkeys, num, data, pos, data_len); | ||
} | ||
|
||
event_pubkeys::event_pubkeys(FILE* fp, int32_t height) : event(EVENT_PUBKEYS, height) | ||
event_pubkeys::event_pubkeys(FILE* fp, int32_t height) : event_pubkeys(height) | ||
{ | ||
num = fgetc(fp); | ||
if ( fread(pubkeys,33,num,fp) != num ) | ||
|
@@ -160,7 +160,7 @@ std::ostream& operator<<(std::ostream& os, const event_pubkeys& in) | |
return os; | ||
} | ||
|
||
event_rewind::event_rewind(uint8_t *data, long &pos, long data_len, int32_t height) : event(EVENT_REWIND, height) | ||
event_rewind::event_rewind(uint8_t *data, long &pos, long data_len, int32_t height) : event_rewind(height) | ||
{ | ||
// nothing to do | ||
} | ||
|
@@ -171,11 +171,10 @@ std::ostream& operator<<(std::ostream& os, const event_rewind& in) | |
return os; | ||
} | ||
|
||
event_notarized::event_notarized(uint8_t *data, long &pos, long data_len, int32_t height, const char* _dest, bool includeMoM) | ||
: event(EVENT_NOTARIZED, height), MoMdepth(0) | ||
event_notarized::event_notarized(uint8_t *data, long &pos, long data_len, int32_t height, | ||
const char* _dest, bool includeMoM) | ||
: event_notarized(height, dest) | ||
{ | ||
strncpy(this->dest, _dest, sizeof(this->dest)-1); | ||
this->dest[sizeof(this->dest)-1] = 0; | ||
MoM.SetNull(); | ||
mem_read(this->notarizedheight, data, pos, data_len); | ||
mem_read(this->blockhash, data, pos, data_len); | ||
|
@@ -188,10 +187,8 @@ event_notarized::event_notarized(uint8_t *data, long &pos, long data_len, int32_ | |
} | ||
|
||
event_notarized::event_notarized(FILE* fp, int32_t height, const char* _dest, bool includeMoM) | ||
: event(EVENT_NOTARIZED, height), MoMdepth(0) | ||
: event_notarized(height, dest) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here: it seems 'dest' is not initialised yet |
||
{ | ||
strncpy(this->dest, _dest, sizeof(this->dest)-1); | ||
this->dest[sizeof(this->dest)-1] = 0; | ||
MoM.SetNull(); | ||
if ( fread(¬arizedheight,1,sizeof(notarizedheight),fp) != sizeof(notarizedheight) ) | ||
throw parse_error("Invalid notarization height"); | ||
|
@@ -223,15 +220,15 @@ std::ostream& operator<<(std::ostream& os, const event_notarized& in) | |
return os; | ||
} | ||
|
||
event_u::event_u(uint8_t *data, long &pos, long data_len, int32_t height) : event(EVENT_U, height) | ||
event_u::event_u(uint8_t *data, long &pos, long data_len, int32_t height) : event_u(height) | ||
{ | ||
mem_read(this->n, data, pos, data_len); | ||
mem_read(this->nid, data, pos, data_len); | ||
mem_read(this->mask, data, pos, data_len); | ||
mem_read(this->hash, data, pos, data_len); | ||
} | ||
|
||
event_u::event_u(FILE *fp, int32_t height) : event(EVENT_U, height) | ||
event_u::event_u(FILE *fp, int32_t height) : event_u(height) | ||
{ | ||
if (fread(&n, 1, sizeof(n), fp) != sizeof(n)) | ||
throw parse_error("Unable to read n of event U from file"); | ||
|
@@ -253,14 +250,16 @@ std::ostream& operator<<(std::ostream& os, const event_u& in) | |
return os; | ||
} | ||
|
||
event_kmdheight::event_kmdheight(uint8_t* data, long &pos, long data_len, int32_t height, bool includeTimestamp) : event(EVENT_KMDHEIGHT, height) | ||
event_kmdheight::event_kmdheight(uint8_t* data, long &pos, long data_len, int32_t height, | ||
bool includeTimestamp) : event_kmdheight(height) | ||
{ | ||
mem_read(this->kheight, data, pos, data_len); | ||
if (includeTimestamp) | ||
mem_read(this->timestamp, data, pos, data_len); | ||
} | ||
|
||
event_kmdheight::event_kmdheight(FILE *fp, int32_t height, bool includeTimestamp) : event(EVENT_KMDHEIGHT, height) | ||
event_kmdheight::event_kmdheight(FILE *fp, int32_t height, bool includeTimestamp) | ||
: event_kmdheight(height) | ||
{ | ||
if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) ) | ||
throw parse_error("Unable to parse KMD height"); | ||
|
@@ -280,7 +279,8 @@ std::ostream& operator<<(std::ostream& os, const event_kmdheight& in) | |
return os; | ||
} | ||
|
||
event_opreturn::event_opreturn(uint8_t *data, long &pos, long data_len, int32_t height) : event(EVENT_OPRETURN, height) | ||
event_opreturn::event_opreturn(uint8_t *data, long &pos, long data_len, int32_t height) | ||
: event_opreturn(height) | ||
{ | ||
mem_read(this->txid, data, pos, data_len); | ||
mem_read(this->vout, data, pos, data_len); | ||
|
@@ -294,7 +294,7 @@ event_opreturn::event_opreturn(uint8_t *data, long &pos, long data_len, int32_t | |
} | ||
} | ||
|
||
event_opreturn::event_opreturn(FILE* fp, int32_t height) : event(EVENT_OPRETURN, height) | ||
event_opreturn::event_opreturn(FILE* fp, int32_t height) : event_opreturn(height) | ||
{ | ||
if ( fread(&txid,1,sizeof(txid),fp) != sizeof(txid) ) | ||
throw parse_error("Unable to parse txid of opreturn record"); | ||
|
@@ -322,7 +322,8 @@ std::ostream& operator<<(std::ostream& os, const event_opreturn& in) | |
return os; | ||
} | ||
|
||
event_pricefeed::event_pricefeed(uint8_t *data, long &pos, long data_len, int32_t height) : event(EVENT_PRICEFEED, height) | ||
event_pricefeed::event_pricefeed(uint8_t *data, long &pos, long data_len, int32_t height) | ||
: event_pricefeed(height) | ||
{ | ||
mem_read(this->num, data, pos, data_len); | ||
// we're only interested if there are 35 prices. | ||
|
@@ -333,7 +334,8 @@ event_pricefeed::event_pricefeed(uint8_t *data, long &pos, long data_len, int32_ | |
pos += num * sizeof(uint32_t); | ||
} | ||
|
||
event_pricefeed::event_pricefeed(FILE* fp, int32_t height) : event(EVENT_PRICEFEED, height) | ||
event_pricefeed::event_pricefeed(FILE* fp, int32_t height) | ||
: event_pricefeed(height) | ||
{ | ||
num = fgetc(fp); | ||
if ( num * sizeof(uint32_t) <= sizeof(prices) && fread(prices,sizeof(uint32_t),num,fp) != num ) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems 'dest' is not initialised yet (maybe _dest was supposed)