Project

General

Profile

Actions

Bug #4181

closed

Name::end undefined behavior

Added by Junxiao Shi almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Base
Target version:
Start date:
07/11/2017
Due date:
% Done:

100%

Estimated time:
1.00 h

Description

Snippet to reproduce:

// g++ -std=c++11 -o x x.cpp $(pkg-config --cflags --libs libndn-cxx) -fsanitize=undefined

#include <ndn-cxx/name.hpp>

int
main()
{
  ndn::Name n0;
  n0.end();
}

Actual: /usr/include/c++/5/bits/stl_iterator.h:754:17: runtime error: reference binding to null pointer of type 'const struct Block'
Expected: no such error

Additionally, Name::begin() also triggers undefined behavior if name is empty.

Actions #1

Updated by Junxiao Shi almost 7 years ago

  • Assignee set to Junxiao Shi

I can work on this after https://gerrit.named-data.net/4025 is merged.

Actions #2

Updated by Junxiao Shi almost 7 years ago

  • Subject changed from Name::end undefined behavior to Name::end undefined behavior if name.empty()
Actions #3

Updated by Davide Pesavento almost 7 years ago

Actually, both Name::begin() and Name::end() dereference a past-the-end iterator (which is not dereferenceable) if the name is empty.

Actions #4

Updated by Junxiao Shi almost 7 years ago

  • Subject changed from Name::end undefined behavior if name.empty() to Name::end undefined behavior
  • Description updated (diff)
  • Status changed from New to In Progress
Actions #5

Updated by Junxiao Shi almost 7 years ago

  • Status changed from In Progress to Code review
  • % Done changed from 0 to 100
Actions #6

Updated by Junxiao Shi almost 7 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF