Print this page
11414 Fix smatch issue in libdemangle


 222 {
 223         strview_t sv;
 224         strview_t name;
 225         uint64_t len;
 226         size_t rem;
 227         boolean_t last = B_FALSE;
 228 
 229         if (st->rds_error != 0 || sv_remaining(svp) == 0)
 230                 return (B_FALSE);
 231 
 232         sv_init_sv(&sv, svp);
 233 
 234         if (!rustdem_parse_num(st, &sv, &len)) {
 235                 DEMDEBUG("ERROR: no leading length");
 236                 st->rds_error = EINVAL;
 237                 return (B_FALSE);
 238         }
 239 
 240         rem = sv_remaining(&sv);
 241 
 242         if (rem < len || len > SIZE_MAX) {
 243                 st->rds_error = EINVAL;
 244                 return (B_FALSE);
 245         }
 246 
 247         /* Is this the last segment before the terminating E? */
 248         if (rem == len + 1) {
 249                 VERIFY3U(sv_peek(&sv, -1), ==, 'E');
 250                 last = B_TRUE;
 251         }
 252 
 253         if (!first && !rustdem_add_sep(st))
 254                 return (B_FALSE);
 255 
 256         /* Reduce length of seg to the length we parsed */
 257         (void) sv_init_sv_range(&name, &sv, len);
 258 
 259         DEMDEBUG("%s: segment='%.*s'", __func__, SV_PRINT(&name));
 260 
 261         /*
 262          * A rust hash starts with 'h', and is the last component of a name




 222 {
 223         strview_t sv;
 224         strview_t name;
 225         uint64_t len;
 226         size_t rem;
 227         boolean_t last = B_FALSE;
 228 
 229         if (st->rds_error != 0 || sv_remaining(svp) == 0)
 230                 return (B_FALSE);
 231 
 232         sv_init_sv(&sv, svp);
 233 
 234         if (!rustdem_parse_num(st, &sv, &len)) {
 235                 DEMDEBUG("ERROR: no leading length");
 236                 st->rds_error = EINVAL;
 237                 return (B_FALSE);
 238         }
 239 
 240         rem = sv_remaining(&sv);
 241 
 242         if (rem < len || len == SIZE_MAX) {
 243                 st->rds_error = EINVAL;
 244                 return (B_FALSE);
 245         }
 246 
 247         /* Is this the last segment before the terminating E? */
 248         if (rem == len + 1) {
 249                 VERIFY3U(sv_peek(&sv, -1), ==, 'E');
 250                 last = B_TRUE;
 251         }
 252 
 253         if (!first && !rustdem_add_sep(st))
 254                 return (B_FALSE);
 255 
 256         /* Reduce length of seg to the length we parsed */
 257         (void) sv_init_sv_range(&name, &sv, len);
 258 
 259         DEMDEBUG("%s: segment='%.*s'", __func__, SV_PRINT(&name));
 260 
 261         /*
 262          * A rust hash starts with 'h', and is the last component of a name