Skip to content

Commit d63b36a

Browse files
committed
Fixed long line reading from istream.
1 parent 9fbe4fd commit d63b36a

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

docs/RELEASES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## v2.6 29.09.2022
4+
5+
### Fixed
6+
7+
- [issue #9](https://github.com/astand/c-coderdbc/issues/16) found by [@DPOH357](https://github.com/DPOH357)
8+
9+
---
10+
311
## v2.5 26.07.2022
412

513
### Changed

src/codegen/filewriter.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
#include <assert.h>
66
#include "filewriter.h"
77

8-
template<size_t N = 4096>
8+
template<size_t N = 10000>
99
std::string __print_loc__(const char* format, va_list args)
1010
{
11-
// TODO: make N sanitizing here to prevent memory errors
1211
char work_buff[N] = {0};
1312
auto ret = vsnprintf(work_buff, N, format, args);
1413

15-
assert(ret < N);
14+
if (ret >= N)
15+
{
16+
std::cout << "Attention (!) the line has been shortened : " << std::endl;
17+
std::cout << work_buff << std::endl;
18+
}
19+
1620
// make string from local array
1721
return work_buff;
1822
}

src/parser/dbcscanner.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
#include <math.h>
55
#include "../helpers/formatter.h"
66

7-
#define MAX_LINE 4096 * 4
8-
9-
char line[MAX_LINE] = { 0 };
10-
117
MessageDescriptor_t* find_message(vector<MessageDescriptor_t*> msgs, uint32_t ID)
128
{
139
MessageDescriptor_t* ret = nullptr;
@@ -72,9 +68,8 @@ void DbcScanner::ParseMessageInfo(istream& readstrm)
7268

7369
while (readstrm.eof() == false)
7470
{
75-
readstrm.getline(line, MAX_LINE);
76-
77-
sline = str_trim(line);
71+
std::getline(readstrm, sline);
72+
sline = str_trim(sline);
7873

7974
FindVersion(sline);
8075

@@ -160,9 +155,8 @@ void DbcScanner::ParseOtherInfo(istream& readstrm)
160155

161156
while (!readstrm.eof())
162157
{
163-
readstrm.getline(line, MAX_LINE);
164-
165-
sline = str_trim(line);
158+
std::getline(readstrm, sline);
159+
sline = str_trim(sline);
166160

167161
if (lparser.ParseCommentLine(&cmmnt, sline))
168162
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy