diff options
Diffstat (limited to 'src/scripts/genXplatLttng.py')
-rw-r--r-- | src/scripts/genXplatLttng.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/scripts/genXplatLttng.py b/src/scripts/genXplatLttng.py index bacf034868..fae0e120da 100644 --- a/src/scripts/genXplatLttng.py +++ b/src/scripts/genXplatLttng.py @@ -593,7 +593,8 @@ bool ResizeBuffer(char *&buffer, int& size, int currLen, int newSize, bool &fixe bool WriteToBuffer(const BYTE *src, int len, char *&buffer, int& offset, int& size, bool &fixedBuffer) { - if (offset + len) + if (!src) return true; + if (offset + len > size) { if (!ResizeBuffer(buffer, size, offset, size + len, fixedBuffer)) return false; @@ -606,9 +607,10 @@ bool WriteToBuffer(const BYTE *src, int len, char *&buffer, int& offset, int& si bool WriteToBuffer(PCWSTR str, char *&buffer, int& offset, int& size, bool &fixedBuffer) { + if (!str) return true; int byteCount = (PAL_wcslen(str) + 1) * sizeof(*str); - if (offset + byteCount) + if (offset + byteCount > size) { if (!ResizeBuffer(buffer, size, offset, size + byteCount, fixedBuffer)) return false; @@ -621,8 +623,9 @@ bool WriteToBuffer(PCWSTR str, char *&buffer, int& offset, int& size, bool &fixe bool WriteToBuffer(const char *str, char *&buffer, int& offset, int& size, bool &fixedBuffer) { + if (!str) return true; int len = strlen(str) + 1; - if (offset + len) + if (offset + len > size) { if (!ResizeBuffer(buffer, size, offset, size + len, fixedBuffer)) return false; @@ -762,4 +765,4 @@ def main(argv): if __name__ == '__main__': return_code = main(sys.argv[1:]) - sys.exit(return_code)
\ No newline at end of file + sys.exit(return_code) |