c/9557: gcc 2.95.3 20010315 (SuSE) problem with place of variable

bangerth@dealii.org bangerth@dealii.org
Mon Feb 3 23:42:00 GMT 2003

Synopsis: gcc  2.95.3 20010315 (SuSE) problem with place of variable

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Mon Feb  3 23:42:38 2003
    User error -- read sscanf man page:
      struct lien *con;
      short  port;
      con=(struct lien *)malloc(sizeof(struct lien));
      sscanf(n_service, "%d", &port);
      con->adr4.sin_port =1;
    Using a short with %d is bound to write beyond its bounds.
    You overwrite the value of the con pointer, which afterwards
    points to no-go land. Use an integer with %d and your
    program works again. The fact that it worked by exchanging
    variable declarations just means that instead of the con
    pointer, you overwrote the ok flag.


More information about the Gcc-bugs mailing list