Skip to content

Commit

Permalink
Check data APIs nullability for #23490
Browse files Browse the repository at this point in the history
  • Loading branch information
astralia authored Nov 15, 2024
1 parent e14fa9a commit f72f3e0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions libr/anal/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// TODO: integrate this code in a better way.. maybe reftype as name?
R_API int r_anal_data_type(RAnal *anal, ut64 da) {
R_RETURN_VAL_IF_FAIL (anal, R_ANAL_REF_TYPE_NULL);
RIO *io = anal->iob.io;
if (!anal->iob.is_valid_offset (io, da, R_PERM_R)) {
return R_ANAL_REF_TYPE_ERROR;
Expand Down Expand Up @@ -198,14 +199,11 @@ static bool is_bin(const ut8 *buf, int size) {
}

// TODO: add is_flag, is comment?
R_API char *r_anal_data_tostring(RAnalData *d, RConsPrintablePalette *pal) {
R_API char *r_anal_data_tostring(RAnalData *d, R_NULLABLE RConsPrintablePalette *pal) {
R_RETURN_VAL_IF_FAIL (d, NULL);
int i, len, mallocsz = 1024;
ut32 n32;

if (!d) {
return NULL;
}

RStrBuf *sb = r_strbuf_new (NULL);
if (!sb || !r_strbuf_reserve (sb, mallocsz)) {
r_strbuf_free (sb);
Expand Down Expand Up @@ -334,6 +332,7 @@ R_API RAnalData *r_anal_data_new_string(ut64 addr, const char *p, int len, int t
}

R_API RAnalData *r_anal_data_new(ut64 addr, int type, ut64 n, const ut8 *buf, int len) {
R_RETURN_VAL_IF_FAIL (buf, NULL);
RAnalData *ad = R_NEW0 (RAnalData);
int l = R_MIN (len, 8);
if (!ad) {
Expand Down Expand Up @@ -536,7 +535,7 @@ R_API const char *r_anal_data_kind(RAnal *a, ut64 addr, const ut8 *buf, int len)
return "data";
}

R_API const char *r_anal_datatype_tostring(RAnalDataType t) {
R_API R_NULLABLE const char *r_anal_datatype_tostring(RAnalDataType t) {
switch (t) {
case R_ANAL_DATATYPE_NULL:
return NULL;
Expand Down

0 comments on commit f72f3e0

Please sign in to comment.