get_digest_base_metadata used to allow fallback to getting metadata pointer from VALUE created by Data_Wrap_Struct, why has this been changed?
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 51
- Forks
- 37
- Avg merge
- 8h 16m
- Merged PRs (30d)
- 4
Description
Here's the code from 3.3.10 which still allows the fallback. The new changes broke implementations that create the metadata object externally. I could check if rb_digest_make_metadata exists and call it on versions of digest.h where it exists but still call Data_Wrap_Struct (Data_Make_Struct actually) when it doesn't to preserve compatibility in all versions. Unfortunately I can't because my metadata is dynamic as I create one for every custom implementation of the algo, and rb_digest_make_metadata does not accept an argument for the free function.
static rb_digest_metadata_t *
get_digest_base_metadata(VALUE klass)
{
VALUE p;
VALUE obj;
rb_digest_metadata_t *algo;
for (p = klass; !NIL_P(p); p = rb_class_superclass(p)) {
if (rb_ivar_defined(p, id_metadata)) {
obj = rb_ivar_get(p, id_metadata);
break;
}
}
if (NIL_P(p))
rb_raise(rb_eRuntimeError, "Digest::Base cannot be directly inherited in Ruby");
if (!RB_TYPE_P(obj, T_DATA) || RTYPEDDATA_P(obj)) {
wrong:
if (p == klass)
rb_raise(rb_eTypeError, "%"PRIsVALUE"::metadata is not initialized properly",
klass);
else
rb_raise(rb_eTypeError, "%"PRIsVALUE"(%"PRIsVALUE")::metadata is not initialized properly",
klass, p);
}
#undef RUBY_UNTYPED_DATA_WARNING
#define RUBY_UNTYPED_DATA_WARNING 0
Data_Get_Struct(obj, rb_digest_metadata_t, algo);
if (!algo) goto wrong;
switch (algo->api_version) {
case 3:
break;
/*
* put conversion here if possible when API is updated
*/
default:
rb_raise(rb_eRuntimeError, "Incompatible digest API version");
}
return algo;
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with get_digest_base_metadata and the digest.h API, comparing the current behavior with the 3.3.10 implementation shown in the issue. Check how externally created metadata is handled across supported versions; done means preserving compatibility for custom implementations without requiring a fixed metadata free function.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, ruby
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100